我試圖使用UpdateProgress觸發器(請參閱下面的代碼),但是當點擊指派爲asyncPostBackTrigger的按鈕時,UpdateProgress不起作用。 如果我刪除AssociatedUpdatePanelID屬性,則UpdateProgress控件起作用。但是我想配置獨立的UpdateProgress,所以我需要指定UpdateProgress控件的AssociatedUpdatePanelID屬性 。UpdateProgress觸發器不工作
這是行爲,因爲它應該是?
注:我不想攔截Sys.WebForms.PageRequestManager 實例和操縱asyncronous請求手動顯示 和隱藏的UpdateProgress元件。有沒有辦法做到這一點?
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="AjaxExtensionsTest._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<h2>
Ajax Extensions Test
</h2>
<asp:UpdatePanel ID="up1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div id="content">
<asp:TextBox ID="txtDataHora" runat="server"></asp:TextBox>
<asp:UpdateProgress ID="progress1" AssociatedUpdatePanelID="up1" DynamicLayout="true" DisplayAfter="0" runat="server">
<ProgressTemplate>
<div>
<img alt="progress" src="loading.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="btnSubmit" Text="Get Current Date/Time" runat="server" onclick="btnSubmit_Click" />
<p>
</p>
</asp:Content>
<script runat="server" language="csharp">
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager1.RegisterAsyncPostBackControl(btnSubmit);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
txtDataHora.Text = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss");
System.Threading.Thread.Sleep(2000);
}
</script>