Click here to Skip to main content
15,169,249 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How to Use ModalPopUpExtender in asp.net using C#
Posted

1 solution

In the aspx page:

First add ajax toolkit and register in the aspx page as:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


then add

XML
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </cc1:ToolkitScriptManager>


and then:

XML
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
                                <cc1:ModalPopupExtender TargetControlID="btnShowPopup" ID="pnlModal_ModalPopupExtender"
                                    runat="server" DynamicServicePath="" Enabled="True" BackgroundCssClass="modalBackground"
                                    PopupControlID="pnlModal" CancelControlID="btnClose" DropShadow="true">
                                </cc1:ModalPopupExtender>




in this button btnShowPopup with display none is used as fake button.
so that ModalPopUpExtender is called from Code Behind.
otherwise you can use it as ,without display none.


XML
<asp:Panel ID="pnlModal" runat="server" Height="99px" Width="368px">
                                    <table class="mainModalTable" cellpadding="0" height="98px" cellspacing="0" width="368px">
                                        <tr>
                                            <td class="mainModaTableTD">
                                                <table class="mainModalInnerTable" cellspacing="0" cellpadding="0" height="98px"
                                                    width="368px">
                                                    <tr>
                                                        <td class="mainModalInnerTableTD">
                                                            <table border="0" cellspacing="0" cellpadding="4" style="width: 368px" height="98px">
                                                                <tr>
                                                                    <td class="mainModalDraggablePanelTD" align="left">
                                                                        <asp:Panel CssClass="mainModalDraggablePanel" ID="MPD" runat="server">
                                                                            <span class="mainModalTitle" id="spanTitle">
                                                                                <asp:Label ID="lblShowPopUpMsg" runat="server" Font-Size="10px" Text="" ForeColor="White"></asp:Label>
                                                                            </span>
                                                                        </asp:Panel>
                                                                    </td>
                                                                    <td align="right" class="mainModalDraggablePanelCloseTD">
                                                                        <asp:ImageButton SkinID="CloseModal" runat="server" ID="clB" ImageUrl="~/Image/close.gif" />
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="mainModalContentsTD" colspan="2" align="center">
                                                                        <div id="Div3">
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="mainModalContentsTD" colspan="2" align="center">
                                                                        <div id="mainModalContents">
                                                                            <asp:Label runat="server" ID="lblModalPopUp" Font-Bold="true" ForeColor="#3A6EA5" Text="Are you sure to update all assets at once."></asp:Label>
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="mainModalContentsTD" colspan="2">
                                                                        <div id="Div1">
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td class="mainModalContentsTD" colspan="2" align="center">
                                                                        <div id="Div2">
                                                                            <asp:Button ID="btnDone" runat="server" Text="Done" OnClick="btnDone_Click" CausesValidation="false"
                                                                                CssClass="asset-viewer-btn" />&nbsp;&nbsp;
                                                                            <asp:Button ID="btnClose" runat="server" Text="Close" CausesValidation="false" CssClass="asset-viewer-btn" />
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </asp:Panel>





this is the panel used for the ModalPopUp extender.
You can edit it what u want to use.



in the code behind:


C#
protected void btnSaveAllRecords_Click(object sender, EventArgs e)
    {
       
            
            lblShowPopUpMsg.Text = "The page at " + Request.Url.GetLeftPart(UriPartial.Authority) + " says...";
            pnlModal_ModalPopupExtender.Show();
            //UpdateAllTableData();
       
    }



lblShowPopUpMsg.Text = &quot;The page at &quot; + Request.Url.GetLeftPart(UriPartial.Authority) + &quot; says...&quot;;

this label gives you the left part of the url.

thats all.
you can use it in your way..


thanks
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900