Keeping Modal Popups open

Last post 01-24-2008 2:38 PM by Cris Gimenes. 3 replies.

Sort Posts:

  • Keeping Modal Popups open

    07-16-2007, 8:41 PM
    • Member
      4 point Member
    • stephenb3
    • Member since 07-09-2007, 6:18 AM
    • Posts 21

    Hi. I have a Panel and associated ModalPopupExtender inside an UpdatePanel. Is there any way I can preserve the popups status (open or closed) after The UpdatePanel is refreshed? 

    Also, where can I get the class description for the popup class, and other extenders?  Is it in the standard documentation like UpdatePanel is?

     Thanks. 

     

  • Re: Keeping Modal Popups open

    07-20-2007, 4:07 AM
    Answer

    Hi stephenb3,

    To popup the panel automaticly after the Ayncpostback return,Just do it as follow:

    <%@ Page Language="VB" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Label1.Text = DateTime.Now.ToString()
        End Sub

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="always">
                    <ContentTemplate>
                        <asp:Panel ID="Panel1" onscroll="javascript:saveScroll();" runat="server" Height="50px" Width="125px" Style="position: static;
                            overflow: scroll; height: 350px; border: solid 1px blue; background-color: White;
                            display: none;">
                            <table border="0" cellpadding="0" cellspacing="0" width="480px">
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                </tr>
                            </table>
                            <asp:Button ID="Button3" runat="server" Text="Button" />
                        </asp:Panel>
                        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
                        <asp:Button ID="Button2" runat="server" Text="Button" />
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1"
                            CancelControlID="Button3" TargetControlID="Button2">
                        </cc1:ModalPopupExtender>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </form>

        <script type='text/javascript'>
            var scrollLeft = 0;
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

            function EndRequestHandler(sender, args) {
                document.getElementById('Button2').click();
                setScroll();
            }
           
            function setScroll()
            {
                    document.getElementById('<%= Panel1.ClientID %>').scrollLeft = scrollLeft;
            }
            function saveScroll()
            {
                scrollLeft = document.getElementById('<%= Panel1.ClientID %>').scrollLeft;
            }
        </script>

    </body>
    </html>

    The code hit you need is:

            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

            function EndRequestHandler(sender, args) {
                document.getElementById('Button2').click();
            }

    You can check this post for more information:ModalPopupExtender panel scroll position

    You are not merely able to popup the panel automaticly after the Ayncpostback return,You also can maintain the scrollTop/scrollLeft of the panel.

    Best Regards

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
  • Re: Keeping Modal Popups open

    07-20-2007, 11:29 AM
    • Member
      4 point Member
    • stephenb3
    • Member since 07-09-2007, 6:18 AM
    • Posts 21

    Great!  Thanks. 

     

  • Re: Keeping Modal Popups open

    01-24-2008, 2:38 PM
    • Member
      2 point Member
    • Cris Gimenes
    • Member since 01-24-2008, 2:37 PM
    • Posts 1

    Perfect!

Page 1 of 1 (4 items)