How can I make the modal popup scroll its contents with the page?
Asked Answered
M

6

8

I've got a modal popup and when it loads contents that are taller than the browser height I am unable to scroll down to view the rest of the information. Instead the background can scroll but the popup won't.

Instead I'd like to have the popup stay put and when the user scrolls up or down it leave the popup in place and let them scroll to the bottom of the contents. If you make a super long post on Facebook the popup works correctly and I'd like to know how I can get this same effect with this control.

Moreira answered 12/12, 2009 at 18:34 Comment(0)
T
5

In the css of your modal popup, set the width of the modalpop up, then set the overflow:auto. That will give you horizontal scrollbar. Example:

.ModalPopupPanel
{
  width:900px;
  overflow:auto;
}

So,when the content width exceed the 900px, the horizontal scrollbar will show up. The same is true for the vertical scrollbar where you need to set the height of the modalpop.

Timberland answered 5/2, 2010 at 3:20 Comment(1)
That solve the issue if the browser screen is at least 900px. For a solution with a popup that could span to fill that page, see my Answer.Cholon
E
3

You can add a class to the body tag when the popup is open to hide the scrollbar, and remove it when the popup goes away, then your background should be position:fixed and the height should be the window.height() (get it dynamically with JS), and also be overflow:auto.

What happens with all that is that, if the popup is taller than the background, you get a nice scroll bar on the right, and because your body scroll bar is hidden, you see only that one. Also, the page itself doesn't scroll. That's the way Facebook does it with their picture viewer.

Eurydice answered 5/12, 2011 at 19:0 Comment(0)
C
2

This script set the popup height to 90% of the screen height, then you could set the overflow:auto;

<script type="text/javascript">
  function pageLoad() {
      $get('<%= Panel.ClientID %>').style.height = document.documentElement.clientHeight * 0.9 + "px";
  }
    </script> 

here a related question I ask and the solution I found.

asp.net ModalPopupExtender : need to show scroll bar when overflow

Cholon answered 9/5, 2010 at 16:20 Comment(0)
H
0

Put style overflow: auto on the container block.

Haddix answered 12/12, 2009 at 18:49 Comment(2)
When you say container block what are you refering to? Also have you actually testest this? Put two pages of content into a panel that is borught up via the modal popup and without having scroll bars on the panel itself you can see everything by scrolling the page?Moreira
i'm asking because what you suggested does not work when I try it. I know that I can scroll the div and panels but that is not what I am asking about.Moreira
I
0

You can try this for scrolling modalpopup with its contens: Set the PopupDragHandleControlID pointing it to an empty panel, set Reposition mode = "None" this will keep the modal fixed in the same position as you scroll the page.

Irritability answered 8/11, 2012 at 11:15 Comment(0)
M
-1

Here the simple and best working solution

Add that class to your modal popup page.

body.modal-open {
overflow: auto;
}
Mucin answered 20/12, 2015 at 13:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.