ASP.Net:面板中的标签控件未更新

时间:2011-08-14 03:21:27

标签: asp.net dynamic label panel modalpopupextender

我有一个ASP面板,附有一个动态显示的modalpopupextender。在面板内,有两个标签在显示面板弹出窗口时动态填充文本。但是,当显示标签时,标签是空白的(缺失)。下面是我的HTML标记和代码背后的代码:

HTML MARKUP

<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" />&nbsp;<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代码背后

            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.";

什么可能导致标签不显示?

2 个答案:

答案 0 :(得分:4)

您是否在显示模式弹出扩展器的按钮事件中设置标签文本?

如果是这样,“show”事件可能正在客户端处理,并且您的服务器端文本设置代码可能永远不会被调用。

将modalpopupextender包装在UpdatePanel中,并将其更新条件设置为Always。

答案 1 :(得分:0)

上述答案对我不起作用。如果我们将面板保留在更新面板中并在更新面板上调用更新方法,则内容会更新。