Gridview displayed on ModalPopup. Selecting and Paging both causing popup to dissapear.

Last post 07-03-2009 1:31 AM by UydurukAdres. 3 replies.

Sort Posts:

  • Gridview displayed on ModalPopup. Selecting and Paging both causing popup to dissapear.

    07-30-2007, 9:50 AM
    • Member
      point Member
    • Mowie666
    • Member since 07-30-2007, 1:06 PM
    • Posts 3

     I have a gridview being displayed on a modalpopup panel.   It is displaying fine, except that when either I "select" a row for

    display on an accompanying formview, or I choose to visit the next Page of results, the panel disappears.   Any tips

    would be appreciated.   

  • Re: Gridview displayed on ModalPopup. Selecting and Paging both causing popup to dissapear.

    08-03-2007, 5:23 AM
    Answer

    Hi

    When you do Selecting or Paging,a AyncPostback fired.

    So, in fact, the problem is "how to popup the panel automaticly after the Ayncpostback return".

    Check out this link for solution:Keeping Modal Popups open

    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: Gridview displayed on ModalPopup. Selecting and Paging both causing popup to dissapear.

    07-02-2009, 9:11 AM
    • Member
      4 point Member
    • ymeric
    • Member since 11-16-2008, 2:30 PM
    • Ankara, Turkey
    • Posts 4

    This code is not usefull if the modal popup is a pick list. The user can change pages without closing popup but cannot make selection. In fact, the code behind for selection works but the popup does not close. So I need a way to determine whether the user has triggered a select command or a page command to allow and disallow this approach. Does anyone has a solution for that?

    www.e-bit.com.tr
    www.onspeedtr.com
    www.sagligimizicin.com
    www.hukukyazilim.com
  • Re: Gridview displayed on ModalPopup. Selecting and Paging both causing popup to dissapear.

    07-03-2009, 1:31 AM
    • Member
      10 point Member
    • UydurukAdres
    • Member since 05-20-2007, 2:26 PM
    • Ankara, Turkey
    • Posts 5

    I worked hard to achieve the goal but couldn't manage to obtain a result. The objects available at the end of page request are not providing a clue about gridview action. I tried tons of other tricks and none of them seemed to work. So I gave up and disabled paging and added "overflow: scroll; height: 400px;" to panel's style. If I find a solution though I'll share it here.

    www.e-bit.com.tr
    www.onspeedtr.com
    www.sagligimizicin.com
    www.hukukyazilim.com
Page 1 of 1 (4 items)