[英]UpdateProgress with Trigger not working
I´m trying to use UpdateProgress with Triggers (see the code bellow) but when a button assigned as an asyncPostBackTrigger is clicked, the UpdateProgress doesn´t work. 我正在尝试将UpdateProgress与触发器配合使用(请参见下面的代码),但是当单击分配为asyncPostBackTrigger的按钮时,UpdateProgress不起作用。 If I remove the AssociatedUpdatePanelID property, the UpdateProgress control works.
如果删除了AssociatedUpdatePanelID属性,则UpdateProgress控件将起作用。 But I want to configure independent UpdateProgress so, I need to specify the AssociatedUpdatePanelID property of UpdateProgress control.
但是我想配置独立的UpdateProgress,因此,我需要指定UpdateProgress控件的AssociatedUpdatePanelID属性。
Is this behaviour as it is supposed to be? 这是应有的行为吗?
NOTE: I do not want to intercept the Sys.WebForms.PageRequestManager instance and manipulate the asyncronous request to manually display and hide the UpdateProgress element.
注意:我不想拦截Sys.WebForms.PageRequestManager实例并操纵异步请求以手动显示和隐藏UpdateProgress元素。 Is there a way to do that?
有没有办法做到这一点?
<%@ 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>
If you need to use AsyncPostBackTrigger and AssociatedUpdatePanelID then your only option is to handle events on the Sys.WebForms.PageRequestManager instance and manually display and hide the UpdateProgress element. 如果需要使用AsyncPostBackTrigger和AssociatedUpdatePanelID,则唯一的选择是处理Sys.WebForms.PageRequestManager实例上的事件,并手动显示和隐藏UpdateProgress元素。 There is code out there that runs on the server and injects the necessary JavaScript that could be encapsulated into a control to make doing this quite tidy.
服务器上运行着一些代码,并注入了必要的JavaScript,这些JavaScript可以封装到控件中,以使代码整洁。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.