ModalPopupExtender + UpdatePanel

Last post 11-02-2007 2:51 AM by NNM. 11 replies.

Sort Posts:

  • ModalPopupExtender + UpdatePanel

    10-30-2007, 12:15 PM
    • Loading...
    • rmardeni
    • Joined on 10-30-2007, 4:05 PM
    • Posts 6

    Hello Everybody, I have a problem with a complex page I am building, I am using several UpdatePanels and ModalPopupExtenders, in the popups I display forms that after hitting the OK button they do a PostBack and fill grid in custom controls. All this works fine, but the problem I am having is about the behavior of the ModalPopup itself. When I open it the first time it works absolutely perfect, but if I press the Cancel button and open it again several times the background doesn't get locked and I am able to press on other buttons in the page, which is exactly what I am trying to avoid. Anybody has seen this before ????

     I did a test with a page without the UpdatePanel and the ModalPopupExtender works just fine, is just when this is added inside the UpdatePanel that it starts behaving weird. Please any thoughts will help. If i can't get this work I am going to have to get rid of this controls.
     

  • Re: ModalPopupExtender + UpdatePanel

    10-30-2007, 4:16 PM
    • Loading...
    • dan.caswell
    • Joined on 10-30-2007, 6:52 PM
    • Kalamazoo, MI
    • Posts 21

    Is it possible that because the Modal Popup Extender is inside an update panel, that only the update panel is being updated, thus the rest of the page would be unaffected by CSS changes that the modal causes. 

  • Re: ModalPopupExtender + UpdatePanel

    10-31-2007, 10:35 AM
    • Loading...
    • rmardeni
    • Joined on 10-30-2007, 4:05 PM
    • Posts 6

    Ok, I did a few tests and it appears that you are right. The ModalPopupExtender doesn't appear to like to be inside an UpdatePanel, but then how can I make an update just on some controls inside what I want to display in the Modal Popup. Because my idea was that whatever I am going to put in the Modal Popup will generate an asynchronous post back to just process what it is in the Modal Popup and whatever other controls I have in that Update Panel.

     This seems like a really poor control or is just that the documentation is to scarce and there is not actual explanation or full documentation for what can be done with all the controls in the toolkit. This is really frustating.

  • Re: ModalPopupExtender + UpdatePanel

    11-01-2007, 8:35 AM
    • Loading...
    • dan.caswell
    • Joined on 10-30-2007, 6:52 PM
    • Kalamazoo, MI
    • Posts 21

     OK...I found an app I did a while ago that does just what you're asking about.  Basically I have a bunch of modal windows on one page,

    and are called up as necessary. 

    Each Modal popup extender is contained within it's own Update Panel along with the panel that will be popped.

     

     

    <asp:UpdatePanel ID="upAssignApp" runat="server" RenderMode="Inline">
    <ContentTemplate>
    <asp:Panel ID="pnlAssignApp" runat="server" Style="display: none;" CssClass="modalPopup">
    <asp:Button ID="btnDummyAssignApp" runat="server" Text="Button" Style="display: none;" />
    <asp:ListBox ID="lstAssignApp" runat="server" CssClass="lstAdmins" />
    <br />
    <asp:Button ID="btnAssignApp" runat="server" Text="Assign" CssClass="cssButton" OnClick="btnAssignApp_Click" />
    <asp:Button ID="btnCancelAssignApp" runat="server" Text="Cancel" CssClass="cssButton" />
    </asp:Panel>
    <cc1:ModalPopupExtender ID="mpeAssignApp" runat="server" PopupControlID="pnlAssignApp"
    TargetControlID="btnDummyAssignApp" BackgroundCssClass="modalBackground" />
    </ContentTemplate>
    </asp:UpdatePanel>
     
    The only thing that may be different is the way in which I call the popup.  I do it from code instead of having it setup for a button on the page.
    See how I have btnDummyAssignApp as the TargetControlID?  You can't actually click that dummy button, because I have it styled with 
    "display:none;".  So call it from the server with this.
     --
    mpeAssignApp.Show()
     --
      
  • Re: ModalPopupExtender + UpdatePanel

    11-01-2007, 9:14 AM
    • Loading...
    • rmardeni
    • Joined on 10-30-2007, 4:05 PM
    • Posts 6

    Thank you Dan, but this doesn't fix my problem, in fact I think this problem is something that will happen to anybody just trying to do the same I am doing. At first I thought that maybe the RenderMode property of the UpdatePanel would fix it, since its the only difference between my code and yours, but it doesn't. The thing is whenever there are CollapsiblePanelExtenders in the page and the ModalPopupExtender is inside an UpdatePanel, the modal popup doesn't behave properly.

    At the end you will find my test page so you can test it and see if there is something that can be done to overcome this. To reproduce the problem just click on the button and then press the Yes button in the modal popup, once the page has reloaded, press the button again, and you will see that now the horizontal scroll appears, even though nothing has actually changed in the page (just the text of a label). Then if you expand one panel and open the dialog, then cancel the dialog, and repeat the operation one or several times with both panels, you will see that eventually the modadl popup will not cover the whole screen, leaving you a chance to click on whatever is not covered by the grayed out area. 

    CONTENTS OF ModalPopupTest.aspx.cs

    using System;

    using System.Data;

    using System.Configuration;

    using System.Collections;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    public partial class ModalPopupTest : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    Page.ClientScript.GetPostBackEventReference(
    this, String.Empty);

    }

    protected void YesButton_Click1(object sender, EventArgs e)

    {

    // Code to delete the item goes here...

    Label1.Text = "Item deleted";

    }

    }

    CONTENTS OF ModalPopupTest.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModalPopupTest.aspx.cs" Inherits="ModalPopupTest" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title>Untitled Page</title>

    <script type="text/javascript">

    function onYes() {__doPostBack('YesButton', '');

    }

     

    function onNo() {document.getElementById('Label1').innerText = 'Action canceled';

    }

    </script>

    <style type="text/css">

    body {

    font:normal 10pt/13pt Arial, Verdana, Helvetica, sans-serif;

    color:#666;

    margin:20px;

    }

     

    /*Modal Popup*/

    .modalBackground {

    background-color:#000;

    filter:alpha(opacity=80);

    opacity:0.8;

    }

    .modalPopup img {

    border:solid 5px #fff;

    }

    .modalPopup-text {

    display:block;

    color:#000;

    background-color:#fff;

    text-align:center;

    border:solid 2px #000;

    padding:10px;

    }

    .modalPopup-text input {

    width:75px;

    }

    .feedback

    {

    color: #00cc00;

    font-weight: 700;

    }

    </style> </head>

    <body>

    <form id="form1" runat="server">

    <div>

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

    </asp:ScriptManager>

    </div>

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page. This is just text to fill up the page. This is just text to fill up

    the page.&nbsp;<br />

    <br />

    <br />

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page. This is just text to fill up the page. This is just text to fill up

    the page. This is just text to fill up the page.

    <br />

    This is just text to fill up the page.

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page. This is just text to fill up the page. This is just text to fill up

    the page. This is just text to fill up the page. This is just text to fill up the

    page. This is just text to fill up the page. This is just text to fill up the page.

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page.

    <br />

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page. This is just text to fill up the page. This is just text to fill up

    the page. This is just text to fill up the page. This is just text to fill up the

    page. This is just text to fill up the page. This is just text to fill up the page.

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page.

    <br />

    <br />

    <ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"

    CollapseControlID="Panel1" ExpandControlID="Panel1" TextLabelID="Label2" ImageControlID="Image1"

    CollapsedText="collapsed" ExpandedText="expanded" Collapsed="true" CollapsedImage="~/images/collapse_blue.jpg"

    ExpandedImage="~/images/expand_blue.jpg" TargetControlID="Panel2" SuppressPostBack="true"

    ScrollContents="false" CollapsedSize="0">

    </ajaxToolkit:CollapsiblePanelExtender>

    <asp:Panel ID="Panel1" runat="server" Width="800px" Height="25px" Style="text-align: right;

    border: solid 1px Black;">

    Click

    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>&nbsp;<asp:Image ID="Image1"

    runat="server" ImageUrl="~/images/expand_blue.jpg" /></asp:Panel>

    <asp:Panel ID="Panel2" runat="server" Width="800px" Style="color: Red; border: solid 1px Blue;">

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page.

    <br />

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page.

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page. This is just text to fill up the page. This is just text to fill up

    the page. This is just text to fill up the page. This is just text to fill up the

    page. This is just text to fill up the page. This is just text to fill up the page.

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page.

    <br />

    </asp:Panel>

    <br />

    <ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server"

    CollapseControlID="Panel3" ExpandControlID="Panel3" TextLabelID="Label3" ImageControlID="Image2"

    CollapsedText="collapsed" ExpandedText="expanded" Collapsed="true" CollapsedImage="~/images/collapse_blue.jpg"

    ExpandedImage="~/images/expand_blue.jpg" TargetControlID="Panel4" SuppressPostBack="true"

    ScrollContents="false" CollapsedSize="0">

    </ajaxToolkit:CollapsiblePanelExtender>

    <asp:Panel ID="Panel3" runat="server" Width="800px" Height="25px" Style="text-align: right;

    border: solid 1px Black;">

    Click

    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>&nbsp;<asp:Image ID="Image2"

    runat="server" ImageUrl="~/images/expand_blue.jpg" /></asp:Panel>

    <asp:Panel ID="Panel4" runat="server" Width="800px" Style="color: Red; border: solid 1px Blue;">

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page.

    <br />

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page.

    <br />

    <br />

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page. This is just text to

    fill up the page. This is just text to fill up the page. This is just text to fill

    up the page. This is just text to fill up the page. This is just text to fill up

    the page. This is just text to fill up the page. This is just text to fill up the

    page. This is just text to fill up the page. This is just text to fill up the page.

    This is just text to fill up the page. This is just text to fill up the page. This

    is just text to fill up the page. This is just text to fill up the page. This is

    just text to fill up the page. This is just text to fill up the page. This is just

    text to fill up the page. This is just text to fill up the page. This is just text

    to fill up the page. This is just text to fill up the page.

    <br />

    </asp:Panel>

    &nbsp;&nbsp;<br />

    <br />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline">

    <ContentTemplate>

    <asp:Button ID="DeleteButton" runat="server" Text="Delete" /><br />

    <asp:Panel ID="ConfirmtionPanel" runat="server" CssClass="modalPopup" Style="display: none">

    <div class="modalPopup-text">

    Are you sure you want to delete this item?<br />

    <br />

    <asp:Button ID="YesButton" runat="server" Text="Yes" OnClick="YesButton_Click1" />&nbsp;&nbsp;

    <asp:Button ID="NoButton" runat="server" Text="No" />

    </div>

    </asp:Panel>

    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="DeleteButton"

    PopupControlID="ConfirmtionPanel" OkControlID="YesButton" OnOkScript="onYes()"

    CancelControlID="NoButton" OnCancelScript="onNo()" BackgroundCssClass="modalBackground">

    </ajaxToolkit:ModalPopupExtender>

    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>

    </ContentTemplate>

    <Triggers>

    <asp:AsyncPostBackTrigger ControlID="YesButton" EventName="Click" />

    </Triggers>

    </asp:UpdatePanel>

    </form> </body>

    </html>

  • Re: ModalPopupExtender + UpdatePanel

    11-01-2007, 9:51 AM
    • Loading...
    • dan.caswell
    • Joined on 10-30-2007, 6:52 PM
    • Kalamazoo, MI
    • Posts 21

     Hello,

    I'm sorry to say, I cannot reproduce this behavior.  I've run the code several times now, in the same order that you suggested clicking items, and the modal popup covers the whole screen every time.  One question:  What version of the AJAX toolkit are you using (go into your toolbox, right-click, choose items.  Then look for any of the AjaxControlToolkit objects, and let me know what the version is.  I believe mine is an older build.  1.0.10123.0, but everything works for me...

  • Re: ModalPopupExtender + UpdatePanel

    11-01-2007, 10:03 AM
    • Loading...
    • NNM
    • Joined on 09-07-2006, 5:04 AM
    • Posts 484

    dan.caswell:
    The only thing that may be different is the way in which I call the popup.  I do it from code instead of having it setup for a button on the page.
    See how I have btnDummyAssignApp as the TargetControlID?  You can't actually click that dummy button, because I have it styled with 
    "display:none;".  So call it from the server with this.
     --
    mpeAssignApp.Show()
     --

      

    Just today I've been working on a complicated user details page that is built exactly as Dan says, with several modal panels inside updatepanels, some called from datagrid links. It works best as he described and you get full control of what posts back and how using the methods .Show() and .Hide() and .Update() for the updatePanel when necessary.

    I'd mark his post as answer if I could..

    Validation Complete
    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
    I'll always mark your post(s) as answer when it is!
  • Re: ModalPopupExtender + UpdatePanel

    11-01-2007, 10:22 AM
    • Loading...
    • rmardeni
    • Joined on 10-30-2007, 4:05 PM
    • Posts 6

    I have to apologyze with everybody that helped in this post, because I just found the real reason for this weird behavior of the controls. It has nothing to do with the controls themselves but with my browser, which happens to be IE6. I just ran quick tests in both IE7 and FireFox and this problem is not present in neither of those browsers.

    I just wonder why isn't IE6 fully supported? The problem with this now is that I cannot use this control because in this company they still use IE6 as the default browser, so until there is a fix to this issue within the Ajax Toolkit or the company moves to IE7, I can't do anything.

     Thank you all again for your help.

  • Re: ModalPopupExtender + UpdatePanel

    11-01-2007, 10:31 AM
    • Loading...
    • dan.caswell
    • Joined on 10-30-2007, 6:52 PM
    • Kalamazoo, MI