[英]Why can't I change the label under my UpdateProgress div?
<asp:UpdateProgress ID="PreLoader" runat="server" ClientIDMode="Static">
<ProgressTemplate>
<div class="divWaiting">
<asp:Image ID="preload" runat="server" ImageUrl="/Images/preloader.gif" /> 
<asp:Label ID="pmtProc1" runat="server" Text="Payment Processing ... Please Wait" ></asp:Label>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
我似乎无法在代码隐藏区中访问pmtProc1
,为什么?
页面中不包含模板中的任何服务器端控件(例如,诸如<asp:Repeater>
, <asp:GridView>
和<asp:UpdateProgress>
<asp:GridView>
)。
在这种情况下,您需要对<asp:UpdateProgress>
控件本身执行.FindControl
。
例如...
Label pmtProc1 = (Label)PreLoader.FindControl("pmtProc1");
pmtProc1.Text = "New Text";
请注意 ,这不适用于可以出现多个模板的控件(例如<asp:Repeater>
和<asp:GridView
)...在这种情况下,您需要找到有问题的item
,然后在其中找到控件该项目。
例如...
Label lbl = (Label)myRepeater.Items[0].FindControl("myLabel");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.