【问题标题】:Problem with execute two query functions in asp.net webform code behind在asp.net webform代码后面执行两个查询函数的问题
【发布时间】:2021-09-20 19:55:36
【问题描述】:

我有一个要等待的框,我希望先显示该框,然后在 5 秒后将其移除。 我为他写了两个jquery函数 一个显示一个不显示 第一个功能正常工作 但是当我调用第二个函数时,第一个函数的原理不起作用,没有一个函数被执行。

protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "OpenWaitingPagePopup()", true);
        System.Threading.Thread.Sleep(5000);
        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction2", "CloseWaitingPagePopup()", true);
    }

我的 jquery 函数是:

 <script type="text/javascript">
        function OpenWaitingPagePopup() {
            $(".waiting-loader-layer").fadeIn("fast");
        }
        function CloseWaitingPagePopup() {
            $(".waiting-loader-layer").fadeOut();
        }
</script>

我等待的弹出窗口是:

  <!-- waiting popup -->
  <div class="waiting-loader-layer">
   <div class="inner">
    <img src="https://www.pekbag.ir/images/ajax-loader-cs.gif" width="50" height="50">
    <span> Please wait ... </span>
</div>
 </div>

jQuery 文件也已正确添加到页面中。

【问题讨论】:

    标签: c# jquery asp.net


    【解决方案1】:

    这在页面加载时起作用

    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "OpenWaitingPagePopup()", true);
    System.Threading.Thread.Sleep(5000);
    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction2", "CloseWaitingPagePopup()", true);
    

    他们调用延迟 5 秒,但延迟是在服务器端,而不是在客户端。这些结果是在浏览器上同时呈现两个调用(显示和隐藏) - 所以它不像你想象的那样工作。

    您必须找到另一种等待方式,并且必须在客户端。

    【讨论】:

      【解决方案2】:

      这是我的网站: https://www.pekbag.ir/Bag/%DA%A9%DB%8C%D9%81-%D9%84%D9%BE-%D8%AA%D8%A7%D9%BE 我在过滤器的某些部分使用了 Ajax。 我想我必须用 Ajax 来实现整个站点过滤系统。 谢谢阿里斯托斯。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-08-03
        • 1970-01-01
        • 2018-05-29
        • 1970-01-01
        • 1970-01-01
        • 2022-07-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多