按钮点击时的 BlockUI jQuery

发布于 2024-12-17 00:42:36 字数 1354 浏览 3 评论 0 原文

答案:此问题的解决方法如下:

将选择器从 $('#Button3') 更改为 $('#<%= Button3.ClientID % >')

感谢尤里。

问题

我正在尝试获取一个按钮单击来运行JQuery BlockUI 插件。我遇到了一些问题,这是我第一次尝试 JQuery。我确实有 Hello World 弹出示例正在运行,所以我想我已经很接近了,但可以使用一些帮助来解决其余的问题。

这是代码...

<script src="../../scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script src="../../scripts/jquery.blockUI.js" type="text/javascript"></script>

<script type="text/javascript">
 $(document).ready(function() {
     $("#Button3").click(function() {
     $.blockUI();

     setTimeout(function() {
         $.unblockUI({
             onUnblock: function() { alert('onUnblock'); }
         });
     }, 2000);
   });
});

</script>

我试图在 aspx 页面上运行它。如前所述,Hello World 弹出窗口有效,但 blockUI 无效。

任何帮助将不胜感激。

这是按钮 aspx...

 <td>
      <asp:Button ID="Button3" runat="server" Text="Button" />
  </td>

按钮上的事件背后没有代码。

此 apsx 页面也有一个母版页。

在 Visual Studio 中关闭页面时,对代码的一些调整导致了此错误...

Microsoft JScript 运行时错误:Sys.ArgumentTypeException:对象 类型“Sys._Application”无法转换为类型 “系统._应用程序”。参数名称:实例

ANSWER: The fix for this problem is this :

Change selector from $('#Button3') to $('#<%= Button3.ClientID %>')

Thanks to Yuri.

ISSUE:

I am trying to get a button click to run the JQuery BlockUI plugin. I am having some issues this is my first shot at JQuery. I do have the Hello World pop-up example working so I think I am close but could use some help getting the rest worked out.

Here is the code...

<script src="../../scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script src="../../scripts/jquery.blockUI.js" type="text/javascript"></script>

<script type="text/javascript">
 $(document).ready(function() {
     $("#Button3").click(function() {
     $.blockUI();

     setTimeout(function() {
         $.unblockUI({
             onUnblock: function() { alert('onUnblock'); }
         });
     }, 2000);
   });
});

</script>

I am trying to run this on an aspx page. As stated the Hello World popup works but not the blockUI.

Any help would be appreciated.

Here is the button aspx...

 <td>
      <asp:Button ID="Button3" runat="server" Text="Button" />
  </td>

no code behind events on the button.

This apsx page has a Master Page as well.

Some tweaks to the code have prodcued this error when closing the page in Visual Studio...

Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of
type 'Sys._Application' cannot be converted to type
'Sys._Application'. Parameter name: instance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绾颜 2024-12-24 00:42:36

首先,您必须阻止 UI。只有这样才会被解封。您无法取消阻止未阻止的内容,因为已取消阻止==未阻止

因此,请取消注释代码的按钮单击事件中的第一行。

演示:http://jsfiddle.net/naveen/D9GCj/1/

请注意< code>asp:Button 将呈现为 input type="submit"

First you have to block the UI. then only will it be unblocked. You cannot unblocked something that is not blocked as unblocked == not blocked.

So uncomment the first line inside the button click event of your code.

Demo: http://jsfiddle.net/naveen/D9GCj/1/

Please note that asp:Button will be rendered as input type="submit"

药祭#氼 2024-12-24 00:42:36

您可以尝试这种方式

$(document).ready(
    function() {
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(onRequestStart)
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onRequestEnd)
    }
);

function onRequestStart() {
    $.blockUI();
}

function onRequestEnd() {
    $.unblockUI();
} 

Button OnClick:

Protected Sub OnClick(sender As Object, e As EventArgs)
    Thread.Sleep(5000)
    Button1.Text = "Done"
End Sub

You can try this way

$(document).ready(
    function() {
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(onRequestStart)
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onRequestEnd)
    }
);

function onRequestStart() {
    $.blockUI();
}

function onRequestEnd() {
    $.unblockUI();
} 

Button OnClick:

Protected Sub OnClick(sender As Object, e As EventArgs)
    Thread.Sleep(5000)
    Button1.Text = "Done"
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文