Bug in ModalPopup? (vertical scrollbar)

Last post 07-04-2009 12:56 PM by mga911. 21 replies.

Sort Posts:

  • Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 4:34 PM
    • Member
      437 point Member
    • leodippolito
    • Member since 08-30-2006, 8:36 AM
    • London UK
    • Posts 120

    Hi!

    I am using AJAX RTM (1.0) and AjaxControlToolkit version 10301.

    I have a page with a table and 3 rows (header, contents, footer). I have also a panel and a modal popup extender for it.

    When I press the button and the ModalPopup is displayed, it adds an undesirable vertical space in my browser window, activating the vertical scrollbar.

    See picture:

     

     

    The following source code reproduces the problem:

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXCTPEnabledWebApplication3._Default" %>
    <%@ Register TagPrefix="AjaxControlToolkit" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit, Version=1.0.10301.0, Culture=Neutral, PublicKeyToken=28f01b0e84b6d53e" %>
    
    <!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>ModalPopup test</title>
        <style type="text/css">
            html, body
            {
    	        margin: 0;
    	        padding: 0;
    	        border: 0;
    	        height: 100%;
    	        width: 100%;
    	        background-color: #ffffff;
    	        color: Black;
    	        font-family: verdana, Arial, sans-serif;
            }
    
            #aspnetForm
            {
    	        width: 100%;
    	        height: 100%;
    	        margin: 0;
    	        padding: 0;	
            }
            
            #mainTable
            {
    	        height: 100%;
    	        width: 100%;
            }
            
            .modalBackground
            {
    	        background-color: Gray;
    	        filter: alpha(opacity=70);
    	        opacity: 0.7;
            }
    
            .modalPopup
            {
    	        background-color: #eff3fb;
    	        border-width: 3px;
    	        border-style: solid;
    	        border-color: Gray;
    	        padding: 10px;
    	        width: 300px;
    	        height: 300px;
    	        font-size: 12px;	
            }
        </style>
    </head>
    <body>
        <form id="aspnetForm" runat="server">
        <asp:ScriptManager ID="scrMgr" runat="server" />
        
        <table id="mainTable" cellpadding="0" cellspacing="0">
        
        <tr id="header" style="height: 60px; background-color: gray;">
            <td> </td>
        </tr>
        
        <tr id="contents">
            <td>
                <asp:Label ID="lblShow" runat="server" Text="Show" Font-Bold="true"></asp:Label>            
            </td>
        </tr>
            
        <tr id="footer" style="height: 60px; background-color: yellow;">
            <td> </td>
        </tr>
        
        </table>
        
        <asp:Panel ID="pnl" runat="server" CssClass="modalPopup" style="display:none;">
            <asp:Button ID="btnHide" runat="server" Text="Hide" />
        </asp:Panel>
        
        <AjaxControlToolkit:ModalPopupExtender ID="mpe" runat="server"
         BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btnHide"
         PopupControlID="pnl" TargetControlID="lblShow" />
        
        <script type="text/javascript">
            function setContentsHeight()
            {
                // get a referece of the contents table row
                var contentsRow = document.getElementById("contents");
                
                // set available height (browser height minus header and footer)
                contentsRow.style.height = (document.documentElement.clientHeight - 60 - 60) + "px";
            }
            setContentsHeight();
            window.onresize = setContentsHeight;
        </script>
        
        </form>
    </body>
    </html>
    
      

     

     

     

    Is there any fix or workaround for this?

    Thanks!

     

  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 5:05 PM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479
    Works fine for me in IE7 and FF2...what browser are you using?  It *could* be because you have mainTable as height:100% and then the modal popup is defined outside of that (even though it is display:none).  Maybe an older browser doesn't interpret this correctly and so the height of the modal popup is added to height:100% of the table.  Shot in the dark though really :)
  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 5:08 PM
    • Member
      437 point Member
    • leodippolito
    • Member since 08-30-2006, 8:36 AM
    • London UK
    • Posts 120

    The problem happens in IE7 and FF2 here.

    I tested from different machines, saw the same problem.

     

     

  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 5:11 PM
    • Contributor
      2,477 point Contributor
    • LSU.Net
    • Member since 03-08-2007, 5:56 PM
    • Louisiana
    • Posts 459
    The problem only happens if your browser window is set to less than 1133 x880 pixels.


    Please remember to "mark as answered" posts that have helped you.

    -----
    http://lsudotnet.blogspot.com
  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 5:14 PM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479
    Doh!  My mistake...it is happening on my machine too.  I moved the Panel pnl into the <td> that contains lblShow and it works OK.
  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 5:15 PM
    • Member
      437 point Member
    • leodippolito
    • Member since 08-30-2006, 8:36 AM
    • London UK
    • Posts 120

    Hmm..

    My desktop resolution is 1280 x 1024.

     

  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 5:18 PM
    • Contributor
      2,477 point Contributor
    • LSU.Net
    • Member since 03-08-2007, 5:56 PM
    • Louisiana
    • Posts 459

    As is mine.  I dragged the window out until the scrollbars went away and then alerted the window size.

     

    Whoa, that's weird.  If the browser starts in fullscreen mode it happens all of the time.  If it starts slightly reduced in size, I am able to drag it out and make the scrollbars go away.


    This may be a browser bug.
     



    Please remember to "mark as answered" posts that have helped you.

    -----
    http://lsudotnet.blogspot.com
  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 6:03 PM
    • Member
      437 point Member
    • leodippolito
    • Member since 08-30-2006, 8:36 AM
    • London UK
    • Posts 120

    LSU, I understand what you mean.

    If the browser starts with a tiny scrollbar (in other words, starts with the browser contents 1% higher than the browser available size), than the ModalPopup displays fine.

    But if the browser starts without a vertical scrollbar, than we have the problem (when the modal popup is displayed, it adds the extra vertical space and scrollbar, as described).

    I wouldn't say it's a browser bug... I don't know, it looks like a Toolkit bug.

    This is not a new page. I was using an older version (that was released together with the RC version of AJAX), and the modal popup was working perfectly.

    Then I upgraded to Ajax RTM and latest Toolkit... and the problem started to happen.

     

  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 6:13 PM
    • Contributor
      2,019 point Contributor
    • Jason Hill
    • Member since 04-23-2006, 3:39 AM
    • Sydney, Australia
    • Posts 479
    Weird.  I moved the panel pnl into the <td> within the <tr id="header"> and I don't get a scroll bar at any resolution now in IE7.
  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-15-2007, 6:13 PM
    • Member
      437 point Member
    • leodippolito
    • Member since 08-30-2006, 8:36 AM
    • London UK
    • Posts 120

    Now I cannot reproduce the modal popup working fine (when the browser starts with a little scrollbar).

    Well, that's definitely confusing...

     

  • Re: Bug in ModalPopup? (vertical scrollbar)

    05-05-2007, 4:03 PM
    • Member
      3 point Member
    • alik
    • Member since 05-05-2007, 7:54 PM
    • Posts 5
    Hi,

    I have (maybe) the same issue as described above. I use ModulPopupExtender to show a div which should fits inside the browser Windows (which is actually less than 1024x768). When the popup dialog is shown, the vertical scrollbar appears. I have investigated the issue using the IE Developer Toolbar in MSIE 7 RTM and have seen the following:
    * The original popup dialog div is enclosed in a new div, which is probably dynamicaly created by the Toolkit.
    * After the new div from the previous point there is one more new div, which does the issue. If the dialog has not been shown yet, the height and width is zero. However, after showing the dialog, it's width is set to slightly more than the browser window width. Also, the height is more then necessary.
    * After scrolling the browser window, the height and/or width parameter of the div is incremented. This mean that after scrolling to the right and left enough (or up and down) I can get really high height and/or width value set to that div.

    PS: The background page is shorter than the popup dialog, if this information is useful.

    Thanks for investigating this issue.
    Filed under:
  • Re: Bug in ModalPopup? (vertical scrollbar)

    05-22-2007, 3:24 AM
    • Member
      34 point Member
    • party42
    • Member since 04-17-2006, 7:19 PM
    • Utrecht
    • Posts 29

     I have the same issues as described above. It tends to happen when I load the modal extender from a master page and try to size it using css:

    .modalbackground
    {
        background-color: #000;
        filter: alpha(opacity=40);
        opacity: 0.4;
    }

    .modalpopup
    {
        background-color: #fff;
        border: 1px solid #1E2C58;
        padding: 5px;
        height: 275px;
        width: 500px;
    }

    When I remove the height & width attributes the popup doesn't create scrollbars (but its really tiny so thats not really an option...).
     

    Regards,
    Nathan Brouwer

    http://www.nathanbrouwer.nl
  • Re: Bug in ModalPopup? (vertical scrollbar)

    03-27-2008, 7:43 AM
    • Member
      223 point Member
    • waheed
    • Member since 06-15-2006, 5:59 AM
    • Posts 65

    has any one got the answer to this question?

    is it really a bug in the modal popup code?

    any plans to fix???

    Waheed Hussain,
    .Net Consultant,
    email:waheed.hussain@hotmail.com.
  • Re: Bug in ModalPopup? (vertical scrollbar)

    04-11-2008, 3:27 PM

    I may have a workaround solution.  After searching through the 11 (!) JavaScript files that ASP.Net includes with the ASP.Net AJAX Control Toolkit, I found out what was going on.  There is a div that's dynamically created on the page called "AJAXPopup_backgroundElement" (where AJAXPopup is the name of the behavior that you've assigned in your ModalPopupExtender tag).  That div is what offers the modal behavior - it sits at a zIndex of 10000 and has a height and width that fills the entire screen.  In IE 6, this div was being positioned at left:2px and top:2px, but its height and width were the FULL size of the screen, hence the need for the scrollbars.

    So, in my JavaScript code, just before $find("AJAXPopup").show(), I added the following code, and it seems to take care of the problem:

        var background = document.getElementById("AJAXPopup_backgroundElement");
    if (background != null) {
    background.style.left = "0";
    background.style.top = "0";
    }

     I hope this helps!

    Regards,
    Andy Douglas

     

  • Re: Bug in ModalPopup? (vertical scrollbar)

    04-28-2008, 6:39 PM
    • Member
      18 point Member
    • pranilrao
    • Member since 04-26-2007, 9:31 PM
    • Posts 9

    I am facing similar problem with modalpopupextender. I tried to access the popup_backgroundElement in javascript both before and after calling the popup.show() method, however I am not able to access this element.

    The difference in the issue is that I am doing show() from server side code, since I have to get some data from the database and load an usercontrol.

    Any comments to resolve this will be appreciated.

    Thanks,

    Pranil

    Please Mark as "Answer" if this helps you. 

Page 1 of 2 (22 items) 1 2 Next >