[英]UpdateProgress not working
I have an UpdateProgress
and I'm trying to show a loading gif
while post back 我有一个UpdateProgress
并且尝试回发时显示loading gif
but this code doesn't work when I click the button. 但是当我单击按钮时,此代码不起作用。
There is nothing happens with with this code and no post back on button click. 使用此代码不会发生任何事情,并且单击按钮后也不会返回任何帖子。
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="true">
<ProgressTemplate>
<asp:Image ID="ImageWait" runat="server" ImageUrl="../images/wait.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="ButtonSave" runat="server" Text="Save" OnClick="ButtonSave_Click" ValidationGroup="Valid1" />
</ContentTemplate>
</asp:UpdatePanel>
protected void ButtonSave_Click(object sender, EventArgs e)
{
// Some code
}
How can I fix this? 我怎样才能解决这个问题?
Manually trigger AsyncPostBackTrigger to your controls inside UpdatePanel and give the ControlID and EventName that will fire: 在UpdatePanel内手动触发AsyncPostBackTrigger到您的控件,并提供将触发的ControlID和EventName:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" > </ContentTemplate> <asp:Button ID="ButtonSave" runat="server" Text="Save" OnClick="ButtonSave_Click" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ButtonSave" EventName="Click" /> </Triggers> </asp:UpdatePanel>
Give an associated UpdatePanel's ID to UpdateProgress: 将关联的UpdatePanel的ID提供给UpdateProgress:
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
And you can test its working in events using System.Threading.Thread.Sleep(3000);
您可以使用System.Threading.Thread.Sleep(3000);
在事件中测试其工作情况System.Threading.Thread.Sleep(3000);
: :
protected void ButtonSave_Click(object sender, EventArgs e) { // delay it for 3 milliseconds System.Threading.Thread.Sleep(3000); //... Here will be your logic }
by default (whan no value is set in the UpdateProgress control) 默认情况下(在UpdateProgress控件中未设置任何值)
DisplayAfter="500"
If your postback is "too fast", UpdateProgress will not show... Try setting it to: 如果您的回发“太快”,UpdateProgress将不会显示...尝试将其设置为:
DisplayAfter="1"
to check if it's working, and than set your desired value 检查它是否正常工作,然后设置所需的值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.