window.showModalDialog and ASP.NET

G

Guest

I'm not quite sure if the problem I'm having is a restriction of
showModalDialog or if there is a way around it.

The web app I am working requires the user to select a record from a list.
I pop this list (generated by a second page) in a second window. When the
user selects a record on the datagrid, I close the second window and submit
the calling page.

If I try to use showModalDialog, the dialog pops up just fine and everything
is rendered correctly. However, as soon as the page posts back a new browser
window is opened with what appears to be the response for the post back.

Is there a way around this behavior?
 
K

Kikoz

This is done by design. Soon you gonna discover that JScript window.history
doesn't exist in modal dialog, too :)
The only way around this prob is to place iFrame inside of a simple static
html page and make the source of that iframe your aspx page. Then it'll post
correctly.

For example:

Simple HTML page - /SIMPLE_HTML_PAGE.html:

<html>
<head>
<script language="javascript">
function InitFrame(){document.all.frContainer.src =
window.dialogArguments;}
</script>
</head>
<body onload="InitFrame();">
<iframe id="frContainer" frameborder="0" height="100%"
width="100%"></iframe>
</body>
</html>


JScript function (simplified) on your "base" page which has "onclick" to
open modal dialog:

function openDamnDialog(url)
{
var returnedValue =
window.showModalDialog("/SIMPLE_HTML_PAGE.html","/URL_OF_ASPX_PAGE_THAT_NEEDS_TO_USE_DIALOG.aspx","help:no;dialogWidth:500px;dialogHeight:400px;resizable:yes;status:no;scroll:no;"));
if(returnedValue)
{
doSomethig();
//Submit the page if you want
formBlah.submit();
}
}


Call this JScript method from your "base" page. Implement some JScript
return value on your aspx list, if you need to. Basically, there is nothing
difficult about this.

Regards,
Kikoz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top