locked
The label text doesn't show up in modalpopupextender , assigned from vb code behind RRS feed

  • Question

  • User-650153396 posted

    Here is the code snippet in aspx page for modalpopupextender:

    <cc1:ModalPopupExtender ID="mpApproveAlert" runat="server" PopupControlID="Panel1" TargetControlID="btnShow"
    CancelControlID="btnClose" BackgroundCssClass="modalBackground">
       </cc1:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style = "display:none">
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="modalPopup_text">
                <asp:Label ID="lblmodalMsg" runat="server" CssClass="modalLabel"   ></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="modalPopup_text">
                  <asp:Button ID="btnSignOut" runat="server" Text="Ok" CssClass="btn btn-primary modal_ok" UseSubmitBehavior="false"></asp:Button> 
    </td>
            <td>
               <asp:Button ID="btnClose" runat="server" CssClass="btn btn-success modalPopup_close" Text="x" />     
            </td>
        </tr>
    </table>   
          </asp:Panel>

    This modal popup is displayed on click of a button:

    Here is the code snippet from where modalpopup label is assigned a text:

    ...some code here...
               lblmodalMsg.Text = "Reservation has been approved successfully!"
                mpApproveAlert.Show()
            Else
                lblmodalMsg.Text = "No data found to approve!"
                lblmodalMsg.Visible = True
                mpApproveAlert.Show()
            End If
    End Sub

    I have tried using updatepanel instead of panel, but of no use.

     

    Friday, July 22, 2016 10:42 AM

Answers

  • User61956409 posted

    Hi Shell.mpsi,

    Do you assign value to Label control lblmodalMsg and call .show() method on btnShow click event?

        Protected Sub btnShow_Click(sender As Object, e As EventArgs)
            'your code here
        End Sub
    

    If you debug the code, you could find the btnShow server-side btnShow_Click event does not fire when you click the button, so text of Label control dose not update.

    You could use a hidden button as Target Control of ModalPopupExtender and then you could update text of Label and show modal on btnShow_Click event.

    <div>
        <asp:Button ID="btnShow" runat="server" Text="Button" OnClick="btnShow_Click" />
        <asp:Button ID="Button1" runat="server" Text="Button" Style="display: none" />
        <asp:ModalPopupExtender ID="mpApproveAlert" runat="server" PopupControlID="Panel1" TargetControlID="Button1"
            CancelControlID="btnClose" BackgroundCssClass="modalBackground">
        </asp:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" Style="display: none">
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="modalPopup_text">
                        <asp:Label ID="lblmodalMsg" runat="server" CssClass="modalLabel" Text=""></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="modalPopup_text">
                        <asp:Button ID="btnSignOut" runat="server" Text="Ok" CssClass="btn btn-primary modal_ok" UseSubmitBehavior="false"></asp:Button>
                    </td>
                    <td>
                        <asp:Button ID="btnClose" runat="server" CssClass="btn btn-success modalPopup_close" Text="x" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </div>
    
        Protected Sub btnShow_Click(sender As Object, e As EventArgs)
            lblmodalMsg.Text = "Reservation has been approved successfully!"
    
            'call show() method to open modal from server side
            mpApproveAlert.Show()
        End Sub
    

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 25, 2016 9:27 AM