You must Sign In to post a response.
  • Category: ASP.NET

    Sub Form in Asp.net Page

    Hi Guys,

    I opening a subform from a main form GridView column click. Now I want to make the main form disable till the subform is closed. Till we close the subform, no action should be performed in the main form, i.e the main form should be disabled in the back of the subform.

    Help me giving an idea.

    Regards,
    Rajabharathi R
  • #764171
    Hai Rajabharathi,
    There could be many ways to do it, but the simplest one is using the javascript window.openDialog method where you can provide the url of the child page and the height and width of the form.
    This will open the new window as a Dialog so that it will prevent the main page to go without closing the dialog form.
    The other way could e using the Model popup extender control under the Ajax control toolkit that can also be used for the same.
    The new Html5 is also having a JavaScript function called as showModalDialog() which can also be used for the same.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #764172
    You can use javascript to accomplish your task, basically 'window.showModalDialog()' method is used to Creates a modal dialog box that displays the specified HTML document.
    var retval = window.showModalDialog(dialog, varArgIn, varOptions);
    see below sample
    <html>
    <body>

    <p>Click the button to show the dialog.</p>

    <button onclick="myFunction()">Show dialog</button>

    <p><b>Note:</b> Use the "Esc" button to close the modal.</p>
    <p><b>Note:</b> The dialog element is only supported in Chrome 37+, Safari 6+ and Opera 24+.</p>

    <dialog id="myDialog">This is a dialog window</dialog>

    <script>
    function myFunction() {
    document.getElementById("myDialog").showModal();
    }
    </script>

    </body>
    </html>

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764177
    Hi,

    You can do it using CSS styles refer below sample


    <style type="text/css">

    .modalBackground
    {
    background-color: Black;
    filter: alpha(opacity=90);
    opacity: 0.8;
    }
    </style>
    <script type="text/javascript">
    function closepopup() {
    $("#<%=pnlPopup.ClientID %>").hide();
    $(".modalBackground").hide();
    }

    </script>
    </head><body> <form id="form1" runat="server"> <div align="center"> <span class="style1"><strong>Ajax Modal PopUp</strong></span><br /> <br />
    <asp:Button ID="btnShowPopup" Text="Show Popup" runat="server" Style="display: none" />
    <cc1:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btnShowPopup"
    PopupControlID="pnlPopup" BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="pnlPopup" runat="server" BackColor="White" Height="100px"
    Width="400px" Style="display: none">
    <table width="100%" style="border: Solid 2px #D46900; width: 100%; height: 100%"
    cellpadding="0" cellspacing="0">
    <tr style="background-image: url(~/Images/header.gif)">
    <td style="height: 10%; color: White; font-weight: bold; padding: 3px; font-size: larger;
    font-family: Calibri" align="left">
    Confirm Box
    </td>
    <td style="color: White; font-weight: bold; padding: 3px; font-size: larger" align="right">
    <a href="javascript:void(0)" onclick="closepopup()">
    <img src="~/Images/Close.gif" style="border: 0px" align="right" /></a>
    </td>
    </tr>
    <tr>
    <td colspan="2" align="left" style="padding: 5px; font-family: Calibri; font-size: 12px;">
    <asp:Label ID="lblCancelText" runat="server" Text="Are you sure you want to cancel?"></asp:Label>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    </td>
    </tr>

    </table>
    </asp:Panel>
    </div> </form></body></html>

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments