[英]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.