Search code examples
asp.netdynamiclabelpanelmodalpopupextender

ASP.Net: label control in panel not updating


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 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 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?


Solution

  • 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.

    Wrap your modalpopupextender in an UpdatePanel and set it's Update condition to Always.