Showing posts with label divs. Show all posts
Showing posts with label divs. Show all posts

Wednesday, March 28, 2012

Modal popup extender and divs

Good day!

First I have to say that the ajax control toolkit is great! Lots and lots of good stuff in there.

Now, I have designed a site that has a header, content and a footer div (to avoid frames, but to simulate the effect.. if there is a better way, please let me know).
The divs are positioned absolutely, and their locations are to some parts calculated during display-time. Here's a small diagram, to help you understand better.

<html><head></head>
<body><form>
<div id="divHeader">...</div>
<div id="divContent">
<div id="anotherDiv">...</div><modalpopupextender />
</div>
<div id="divFooter">...</div>
</form></body></html>

Very simplified, but it displays my setup.

Now to the problem. The modal popup extender displays a black opaque panel, to darken the inaccessible content. With this setup however, it only blocks out the divContent div, not the header nor the footer divs.

Any ideas of how to solve this?

That should not cause the modal background to not cover the header and footer. Could you possibly post a small complete code sample that reproduces this issue?


Ok then. I made a small sample site. I have no hosting, so Ill paste the code here. The codefile only contains the eventhandler btnShowPopup_Click, and all it does is ModalPopupExtender1.Show();. If you want to, I can zip the entire project to a file instead, but I think its more accessible this way, since its not very much code.

So, here we go (with excuses for poor formatting):

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %
<%@. 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title
<script type="text/javascript">
window.onload = Init;
function SetContentSize()
{
divContent.style.top = divHeader.offsetHeight;
}

function Init()
{
window.onresize = SetContentSize;
SetContentSize();
}

</script>
<style type="text/css">
.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="divHeader" style="position:absolute; left: 0px; right: 0px; top:0px; height: 100px;
background-color: #ffcc00; text-align: center; vertical-align: middle;">
This is the header div.<br />
This will not be covered by the extenders overlay.
</div>
<div id="divContent" style="position:absolute; left: 0px; right: 0px; bottom: 0px;
background-color: #ffee99; text-align: center; vertical-align: middle;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
This is the content div.
<asp:Button ID="btnShowPopup" runat="server" Text="Show popup" OnClick="btnShowPopup_Click" />
<asp:Panel Style="border-right: gray 1px solid; border-top: gray 1px solid; display: none;
vertical-align: top; border-left: gray 1px solid; color: black; border-bottom: gray 1px solid;
background-color: #dddddd" ID="pnlPopup" runat="server" HorizontalAlign="Left">
This is text inside the popup!
<asp:Button ID="btnClose" runat="server" Text="Close" />
</asp:Panel>
<asp:Button Style="visibility: hidden" ID="btnHidden1" runat="server"></asp:Button>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow="true"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" PopupControlID="pnlPopup"
TargetControlID="btnHidden1">
</cc1:ModalPopupExtender>
</ContentTemplate></asp:UpdatePanel>
</div>
</form>
</body>
</html>


I should add; Even though the script in my example fills no real function, it does in the live version where my divHeader has a variable height. I included it to be more true to the original.


It seems to be a problem. Thanks for providing a repro. Work Item8796 tracks it.

Thank you for the attention.
I tried replacing the modal popup with an ordinary div. I think one can summarize the problem like this: Internet Explorer can NOT position an absolutely positioned div outside of the absolutely positioned div in which it resides. Therefore, I believe this to be more of a browser problem, than an ajax problem.

I have not tested this on Firefox / Opera / etc.. It would be interesting to see if they can handle it.

Jeez, I just read what I wrote above.. I assure you though; it makes sense if you think about it. Angel

Wednesday, March 21, 2012

ModalPopup : how to cover the whole browser (ie all divs) ?

Hi all,

I have a page with 3 divs : the top div for the menu (navigation), the left div for a thin decoration and the main central div for the content itself.

When I click on one of the items of my repeater, the modalpopup shows up but thegray background only covers the main central div, not the other 2.

Please check the attached screenshot.

My question is : is there a way for mygray background to cover the whole browser ie all my divs ?

thank you

I am also experiencing the same problem. Anyone?

Let me know if you find a solution.


I have done limited testing, however, I was able to fix the problem by modifying the ModalPopupBehavior.js file:

I commented out the appendChild and replaced it with the code block around line number 75 of the script

 //this._foregroundElement.parentNode.appendChild(this._backgroundElement); if (document.forms != null && document.forms.length > 0) { document.forms[0].appendChild(this._backgroundElement); document.forms[0].appendChild(this._foregroundElement); this._foregroundElement.style.zIndex = 10001; }


Here's some background on the issue:http://forums.asp.net/ShowPost.aspx?PostID=1357977

Perhaps you can help me!

I've been looking this issue for quite a bit now. I am using the latest march release of the toolkit now (with my mods). I have changed the initialize to perform the following:

 //this._foregroundElement.parentNode.appendChild(this._backgroundElement); if (document.forms != null && document.forms.length > 0) { document.forms[0].appendChild(this._backgroundElement); document.forms[0].appendChild(this._foregroundElement); this._foregroundElement.style.zIndex = 10001; } else this._foregroundElement.parentNode.appendChild(this._backgroundElement);

All was working fine for me, until I nested a popup within a popop, now I am getting the following error:Sys.InvalidOperationException: Two components with the same id '{0}' can't be added to the application.

I tried a number a variations to the above with no success. I am now playing with the dispose method. Should I give up on this? or continue on the track I am on.

HELP!


Ok, day two of trying to solve my problem. In addition to work item 8360, I wrote a function that zero's out the zIndexes on the show of the modal and resets them when the modal hides. Again, all seemed fine, until I tried to pop a modal from a modal. Is there a global array that will give me the list of all the registered popups? If so I can exclude them from my logic.

I also had to use a property runtimeStyle that is specific to MS IE. We'll have to find a work around for that.

Any help would be appreciated!!!


http://forums.asp.net/1631945/ShowThread.aspx#1631945