ASP.Net:面板中的标签控件未更新 [英] ASP.Net: label control in panel not updating
问题描述
我有一个ASP面板,上面附加了一个modalpopupextender,可以动态显示.面板中有两个标签,当显示面板弹出窗口时,它们会动态地填充文本.但是,显示时,标签为空白(缺失).以下是我的HTML标记和后面的代码:
I have an ASP panel with a modalpopupextender attached to it that is shown dynamically. Within the panel there are two labels that are dynamically populated with text when the panel popup is shown. however, when it is shown the labels are blank (missing). Below is my code for the HTML markup and code behind:
HTML标记
<asp:Panel ID="pnlalert" runat="server" CssClass="modal">
<div class="rel">
<div class="modal-inner-wrapper-alert rounded-corners">
<div class="content rounded-corners">
<div class="body">
<div class="popuppanel">
<div class="popupGnrl-Alert">
<asp:Label ID="alerttitle" runat="server" Text=""></asp:Label><br />
<asp:Label ID="alertlabel" runat="server" Text=""></asp:Label>
<asp:HiddenField ID="section" runat="server" />
<asp:HiddenField ID="violation" runat="server" />
</div>
<div class="popupGnrl-Alert" style="text-align:center;">
<asp:Button ID="cmdMaxAlertOk" runat="server" Text="Yes" Width="50px"
onclick="cmdMaxAlertOk_Click" /> <asp:Button ID="cmdMaxAlertCancel"
runat="server" Text="No" Width="50px" onclick="cmdMaxAlertCancel_Click" />
</div>
</div>
</div>
</div>
</div>
</div>
</asp:Panel>
<asp:ModalPopupExtender ID="mpealert" runat="server" TargetControlID="popuplnk" PopupControlID="pnlalert" >
</asp:ModalPopupExtender>
ASP.NET背后的代码
ASP.NET Code Behind
this.mpealert.Show();
this.alerttitle.Text = "Submission time exceeded";
this.alertlabel.Text = "This expense was incurred greater than 3 months ago and is therefore outside of the normal claim period. Do you still wish to proceed? NOTE: expense may be rejected by Finance.";
是什么原因导致标签不显示?
What could be causing the labels not to show?
推荐答案
您是否在显示模式弹出窗口扩展程序的按钮事件中设置标签的文本?
Are you setting the text of the labels in the button event which shows the modal popup extender?
如果是这样,显示"事件可能是在客户端处理的,而服务器端的文本设置代码可能永远不会被调用.
If so, the "show" event is probably being handled client side and your server side text setting code is probably never being called.
将您的modalpopupextender包装在UpdatePanel中,并将其Update条件设置为Always.
Wrap your modalpopupextender in an UpdatePanel and set it's Update condition to Always.
这篇关于ASP.Net:面板中的标签控件未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!