[英]How to update the content of a userconrol if is outside the update panel?
[英]How to use update progress inside update panel, when the button executing code is outside update panel
我有一个更新面板,里面有更新进度。 我将按钮移到了更新面板之外,因为当我将按钮放在更新面板中时,response.write无法正常工作。 现在,将按钮移到response.write外部之后,更新正常。 外面有按钮时,如何使它工作。
<asp:UpdateProgress ID="UpdateProgress2" runat="server">
<ProgressTemplate>
<div style="width: 338px; position: relative; top: -420px; left: 80px" class=""> <b>Please Wait...</b>
<img runat="server" id="ajaxLoader" style="background-color: White; width: 338px;" src="styles/images/loadImage.gif" alt="loading" />
</div> </ProgressTemplate> </asp:UpdateProgress>
</ContentTemplate> </asp:UpdatePanel>
<asp:Button ID="btn_upload" runat="server" Text="Upload" OnClick="upload_Click" />
将触发器用于更新面板
<asp:UpdatePanel>
.... content ...
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn_upload" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
1.) Response.Write
在设计上无法在UpdatePanel
内部工作(请参阅此处的原因: https : //stackoverflow.com/a/3878111/1288619 )-默认情况下, UpdatePanel
由其所有子控件自动触发。
2.)将按钮放置在按钮外部时,将触发完整的回发,而不是UpdatePanel
的部分呈现-因此没有更新进度。
当您仅将按钮注册为AsyncPostBackTrigger
(无论它在哪里)-您会得到与第一种情况完全相同的情况。
如果将按钮注册为(Full) PostBackTrigger
,或将UpdatePanel
的呈现设置为有条件的,而不是由其子项触发的-那么您将获得与第二种情况完全相同的情况。
因此,按照alexsuslin的建议,只需将UpdatePanel
中某些Literal
控件的text属性更改为您要在Response.Write
放置的内容(然后将按钮的visible属性设置为false,如果您不想再显示它-则请注册作为AsyncPostBackTrigger
如果移到外部)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.