Welcome to MSDN Blogs Sign in | Join | Help

ShowModalDialog

I noticed that the following is an issue thru which people often run: when you show an aspx page (or any server content in general) in a dialog by mean of the javascript ShowModalDialog method, at the first postback you usually witness the instance of a second window, his time a full blown browser, holding in your output.

There is an easy workaround to the situation, but surprisingly it seems that few people knows it: so I'm posting it.

The trick is showing a static page , a simple .htm, in the ShowModalDialog call; such page should hold the active content (your .aspx) in an IFRAME. Subsequent posts will be confined inside the iframe, hence restoring the intended user exprerience.

UPDATE

J proposes a more efficient system: <base target="_self">  in the header of the aspx page yelds to the same result. Thank you J :-)

Published Thursday, June 05, 2003 10:00 PM by vibro

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: ShowModalDialog

Thursday, June 05, 2003 4:14 PM by Jason
<base target="_self">

Sticking that in the header of the ASPX page you're targetting with .showModalDialog() gets the same results....without resorting to the overhead of IFRAME.

- J

# re: ShowModalDialog

Thursday, June 05, 2003 5:02 PM by StingK
Hasn't the target attribute been deprecated?

# re: ShowModalDialog

Thursday, June 05, 2003 9:10 PM by JosephCooney
IIRR turning smartnavigation ON on the aspx that appears in the modal dialog window also gets around this problem. YMMV.

# re: ShowModalDialog

Thursday, June 19, 2003 6:29 PM by Elizabeth Ahola
HI,

I've been struggling with this all day. I used the dummy <Iframe> .html, but had a hard time getting the returnvalue.

I put in the <base....> tag info and that works.

But I am still having trouble getting the returnvalue.

In my Parent window I have
code....
arrModal = window.showModalDialog
("popup.asp",, _
"dialogHeight:30;
dialogWidth:33;edge:Raised;center:Yes;help:No;resizable:No;status:No;")

msgbox arrmodal


in my popup window I have.

code.....
window.returnvalue = "HERE I BE"
window.close

The value of arrModal in the parent window when the popup is close is null.


any ideas? It seems so straight forward.

# re: ShowModalDialog

Friday, June 20, 2003 3:56 AM by Vittorio
Elisabeth, I've heard of this from others but I never had the time to actually check it out. If you don't have problems of security/confidentiality of data, I know that a lot of people used this workaround: you can put your results on a cookie generated for the purpose (use as ID a GUID supplied from the caller at the dialog opening) and retrieve (and delete) it from the caller page as the dialog closes. Let me know if it worked for you.

# re: ShowModalDialog

Friday, August 08, 2003 4:08 AM by 111
11

# re: ShowModalDialog

Wednesday, September 10, 2003 12:12 PM by brendan
window.returnvalue = "HERE I BE"
should be

window.returnValue = "HERE I BE"

# re: ShowModalDialog

Saturday, November 01, 2003 5:44 PM by ed
xxx

# re: ShowModalDialog

Friday, December 05, 2003 5:00 PM by rtyhe
eth45yh4hy

# re: ShowModalDialog

Thursday, January 08, 2004 4:51 AM by f
dfg

# re: ShowModalDialog

Tuesday, January 27, 2004 12:51 PM by Chris Moutray
thanks this fix really got me out of a jam ...

# re: ShowModalDialog

Thursday, January 29, 2004 1:20 PM by Dominique
Hello
I am also facing the same problem.
I have added <base target="_self"> tag just below meta tags in <head>
& also SmartNavigation=true in page directive.
still after post back the page is opening in new IE instance..
please help..

# re: ShowModalDialog

Tuesday, March 02, 2004 9:19 AM by dfas
dfsa

# sdfsdf

Tuesday, March 30, 2004 10:48 AM by sdfsdf
ssdfsdf

# re: ShowModalDialog

Wednesday, April 07, 2004 7:53 PM by test
test

# re: ShowModalDialog

Friday, April 16, 2004 6:55 PM by dsaf
fsda

# re: ShowModalDialog

Monday, May 03, 2004 7:20 PM by dgdf
dg

# re: ShowModalDialog

Monday, May 17, 2004 3:40 PM by dwwe
asodjsodjweodjwedwe

# re: ShowModalDialog

Monday, May 17, 2004 3:40 PM by ssss
ssss

# re: ShowModalDialog

Thursday, May 27, 2004 3:33 AM by Tomas Petricek
Thanks a lot !
I used solution with <base.. /> and i works great.

Tomas

# re: ShowModalDialog<center><b>you</b>

Wednesday, June 02, 2004 3:01 PM by <center><b>you</b>
<center><b>you</b>

# re: ShowModalDialog

Wednesday, June 23, 2004 9:47 PM by ashwini
does the <base target="_self"> work with modal .jsp files too...i tried it ..doesn't work

# re: ShowModalDialog

Friday, June 25, 2004 4:29 PM by drewt
test

# re: ShowModalDialog

Friday, June 25, 2004 4:29 PM by drewt
test

# re: ShowModalDialog

Tuesday, July 20, 2004 9:02 PM by Miguel Madero
I had trouble getting the return value.
I dont know why, but everytime I tried to get the value I just got undefined.

What you can is to define a variable in the opener window and then pass it as the dialogArguments and modify it like:
window.dialogArguments = "new value"

or even better, you can pass the window object as a reference and then update or use any variable.
window.dialogArguments.var1 = "new value";
window.dialogArguments.var2 = "new value";

just open the window this way:
window.showModalDialog("url.htm",window);


I hope this helps.

By the way, thanks for the other tips. I've tried none, but I hope one of those will work for me.

It's weird that doesnt happens with html pages.




# re: ShowModalDialog

Thursday, August 05, 2004 4:51 PM by Davide Senatore
Great tip!
The <base target="_self"> part works great for me!
Thank you very much!

Davide

# The blogosphere saves my ass again

Friday, October 22, 2004 2:43 AM by An attempt at structured thought.
The blogosphere saves my ass again

# Postback e ShowModalDialog

Thursday, August 31, 2006 2:08 AM by UGbLog di Pierre Greborio

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker