ASP.Net: label control in panel not updating

橙三吉。 提交于 2019-12-13 06:56:28

问题


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?


回答1:


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.




回答2:


The above answer did not work for me. If we keep the panel inside an update panel and call the update method on update panel, then the contents get updated.



来源:https://stackoverflow.com/questions/7054778/asp-net-label-control-in-panel-not-updating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!