ModalPopup inside UpdatePanel

Last post 05-14-2008 1:57 PM by jabailo. 16 replies.

Sort Posts:

  • ModalPopup inside UpdatePanel

    03-29-2007, 11:17 AM
    • Loading...
    • CelebesCoder
    • Joined on 05-24-2004, 4:02 PM
    • Connecticut
    • Posts 29

    Hi,

    I'm having problem when doing a postback on a ModalPopup when this extender is inside an UpdatePanel.  The popup screen is always dissapear when I click a button to do postback.  I also try adding UpdatePanel (using either UpdateMode=Always or Conditional) inside the popup panel with the same result. Here is my sample code, and let me know what I'm doing wrong here.

    1    "Content1" ContentPlaceHolderID="MainContent" runat="server">
    2        "ScriptManager1" runat="server">
    3        
    4        "UpdatePanel1" runat="server">
    5            
    6                "Panel1" runat="server" Height="50px" Width="125px">
    7                    "TextBox1" runat="server"> 
    8                    "Button1" runat="server" Text="Button">
    9                    "ModalPopupExtender1" runat="server"
    10                       TargetControlID="Button1"
    11                       PopupControlID="Panel2"
    12                       BackgroundCssClass="DisabledBackground"
    13                       CancelControlID="Button3"     
    14                   >
    15                   
    16                
    17               "Panel2" runat="server" Height="50px" Width="125px">
    18                   "TextBox2" runat="server"> 
    19                   "Button2" runat="server" Text="PostBack"> 
    20                   "Button3" runat="server" Text="Button">
    21                
    22           
    23       
    24   
    25   
    

    Thanks,

    Ricky 

     

  • Re: ModalPopup inside UpdatePanel

    03-29-2007, 12:43 PM
    • Loading...
    • CelebesCoder
    • Joined on 05-24-2004, 4:02 PM
    • Connecticut
    • Posts 29

    The code was cut off, here is to entire test code again. Excuse me for the formatting, but I could not get it to work:

    <

    asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <asp:ScriptManager id="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <asp:UpdatePanel id="UpdatePanel1" runat="server">

    <contenttemplate>

    <asp:Panel id="Panel1" runat="server" Height="50px" Width="125px">

    <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>

    <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>

    <ajaxToolkit:ModalPopupExtender id="ModalPopupExtender1" runat="server"

    TargetControlID="Button1"

    PopupControlID="Panel2"

    BackgroundCssClass="DisabledBackground"

    CancelControlID="Button3"

    >

    </ajaxToolkit:ModalPopupExtender>

    </asp:Panel>

    <asp:Panel id="Panel2" runat="server" Height="50px" Width="125px">

    <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>

    <asp:Button id="Button2" runat="server" Text="PostBack"></asp:Button>

    <asp:Button id="Button3" runat="server" Text="Button"></asp:Button>

    </asp:Panel>

    </contenttemplate>

    </asp:UpdatePanel>

    </

    asp:Content>
  • Re: ModalPopup inside UpdatePanel

    03-29-2007, 2:40 PM
    You shouldn't need an UpdatePanel to accomplish the ModalPopup.  I think it's screwing you up.
    ★ ShepherdWeb
  • Re: ModalPopup inside UpdatePanel

    03-29-2007, 3:33 PM
    • Loading...
    • rustogi18
    • Joined on 03-29-2007, 7:10 PM
    • Posts 6

    Hi,

    I am having problems with refereshing the Modal Popextender. I have 2 buttons on my form which open the same modal popup . In that Popup I am doing some search and showing the results in that same popup. But when I close it using my close button(i have nt written any code in this) and again click the buttons on my form. It shows me the Popup with prefilled result in those fields. I have put all my code in Update panel. The Popup initially comes with some default result, after a search for some values and close the popup and again click the button on the parent form. It shows me the last search result.

    Can you please help me with this problem.

    Thanks in Advance

  • Re: ModalPopup inside UpdatePanel

    03-29-2007, 3:39 PM
    • Loading...
    • Jason Hill
    • Joined on 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 475

    Hiding and showing a modalpopup is done via clientside JS so the last state of the modalpopup is going to be preserved.

    Two options to workaround this:

    1. Allow the modalpopup close button to postback to the server and clear the controls in code
    2. Hookup to the hidden event on the modalpopup in clientside JS and clear the controls in code

     

  • Re: ModalPopup inside UpdatePanel

    03-29-2007, 4:42 PM
    • Loading...
    • CelebesCoder
    • Joined on 05-24-2004, 4:02 PM
    • Connecticut
    • Posts 29

    Guys thanks for all your respond.

    ShepherdWeb, You are right that I don't need the update panel for ModalPopup but It do need the UpdatePanel for other postback stuff inside Panel1.

    Jason, I'm not so concern with the close button (Button3) to close the modal popup.  The issue is regarding the regular postback of any control within my modal panel (not OkControl and CancelControl).  Are saying i must apply the suggested workaround on any control that is doing postback within my modal panel?  If so, can you give me a snippet on how to clear the controls?

    thanks, Ricky

     

  • Re: ModalPopup inside UpdatePanel

    03-29-2007, 4:48 PM
    • Loading...
    • Jason Hill
    • Joined on 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 475

    Sorry Ricky...I was responding to the additional question from rustogi18.  I should have been more specific about!

  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 2:45 PM
    • Loading...
    • CelebesCoder
    • Joined on 05-24-2004, 4:02 PM
    • Connecticut
    • Posts 29

    Anybody has any solution?

    Can this be classified as a bug with ModalPopupExtender control?

    Ricky.

  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 3:00 PM
    Move the ModalPopupExtender and Panel2 outside of the UpdatePanel.
    ★ ShepherdWeb
  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 3:21 PM
    • Loading...
    • CelebesCoder
    • Joined on 05-24-2004, 4:02 PM
    • Connecticut
    • Posts 29

    When moving Panel2 and the extender, will get the following error message.Crying

     An extender can't be in a different UpdatePanel than the control it extends.

  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 3:22 PM
    • Loading...
    • CelebesCoder
    • Joined on 05-24-2004, 4:02 PM
    • Connecticut
    • Posts 29

    When move the Panel2 and the extender outside the updatepanel, I get the following error message.Crying

     An extender can't be in a different UpdatePanel than the control it extends.

  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 5:24 PM
    Hmmm...that message may be referring to Button1 which is still inside the UpdatePanel, right?  Try moving Button1 out of the update panel too.
    ★ ShepherdWeb
  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 6:07 PM
    • Loading...
    • Jason Hill
    • Joined on 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 475

    If you are doing a postback from the modalpopup then you will probably want the modalpopup wrapped in an updatepanel so that you get an async postback.  Try this on for size:

            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
                <ContentTemplate>
                    <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <asp:Button ID="Button1" runat="server" Text="Button"></asp:Button>
                        <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button1"
                            PopupControlID="Panel2" BackgroundCssClass="DisabledBackground" CancelControlID="Button3">
                        </ajaxToolkit:ModalPopupExtender>
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
            <asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="conditional">
                    <ContentTemplate>
                        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                        <asp:Button ID="Button2" runat="server" Text="PostBack"></asp:Button>
                        <asp:Button ID="Button3" runat="server" Text="Button"></asp:Button>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:Panel>

     
  • Re: ModalPopup inside UpdatePanel

    03-30-2007, 6:10 PM
    • Loading...
    • Jason Hill
    • Joined on 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 475

    PS. When you are finished with the popup, you will need to call UpdatePanel1.Hide() manually to hide it and also UpdatePanel1.Update() so that the modified state of ModalPopupExtender1 gets sent to the browser.

  • Re: ModalPopup inside UpdatePanel

    05-11-2007, 6:20 AM