单击按钮后的加载指示器

单击按钮后的加载指示器

本文介绍了单击按钮后的加载指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户单击执行几个SQL查询的按钮后显示一个加载指示器.我尝试取消隐藏按钮单击上的div,但是直到完成按钮后面的所有工作后,该按钮才会显示.我也尝试过此解决方案,但没有成功- http://forums.asp.net/t/1608046.aspx/1

I'm wanting to show a loading indicator after the user has clicked a button that executes several SQL queries. I tried unhiding a div on button click but that doesn't show up until all the work behind the button is complete. I also tried this solution without success - http://forums.asp.net/t/1608046.aspx/1

有什么建议吗?

code

<asp:Button ID="loadButton" OnClientClick="ShowDiv()" runat="server"
onclick="loadButton_Click" Text="Go" />


<script type="text/javascript">
    function ShowDiv()
    {setTimeout('document.getElementById("updatediv").style.display = "inline";', 500);}}
</script>


<div ID="updatediv" runat="server" >
<img src="Images/ajax-loader.gif"  /> Updating ....
</div>

code

使用上面的链接的解决方案时出现以下错误:

I get the following error when using the linked solution above:

**这似乎可以解决问题

**This seemed to do the trick

code

<script type="text/javascript" language="javascript">
function ShowDiv()
   $('#updatediv').show() }
</script>

code

推荐答案

您需要在客户端而不是服务器端设置show div.除了服务器端Click事件之外,ASP按钮还有一个方便的OnClientClick.

You'll need to have the show div on the client side, not the server side. ASP buttons have a handy OnClientClick in addition to the server side Click event.

这当然是您显示的链接的作用.如果您遵循它,那么它不应该等待完成回发的执行.

This is of course what the link that you show does. If you followed it, then it shouldn't be waiting to finish the postback to execute.

这篇关于单击按钮后的加载指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:04