•参数类型:BeginRequestEventArgs
–request属性:用于获得WebRequest对象(用于请求的信息)
–postBackElement:触发异步刷新的DOM元素
•常用操作:
–读取请求信息
–改变请求方式(替换Executor)
–显示更新提示
强制显示UpdateProgress
aspx
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%= DateTime.Now %><br />
<asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button_OnClick" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" DynamicLayout="false"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<span style="color:Red">Loading</span>
</ProgressTemplate>
</asp:UpdateProgress>
<hr />
<asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button_OnClick" />
<script language="javascript" type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(
function(sender, e)
{
if (e.get_postBackElement().id != "<%= this.Button2.ClientID %>")
{
return;
}
var updateProgress = $get("<%= this.UpdateProgress1.ClientID %>");
var dynamicLayout = <%= this.UpdateProgress1.DynamicLayout.ToString().ToLower() %>;
if (dynamicLayout)
{
updateProgress.style.display = "block";
}
else
{
updateProgress.style.visibility = "visible";
}
});
</script>
</asp:Content>
{
}
protected void Button_OnClick(object sender, EventArgs e)
{
Thread.Sleep(2000);
}