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.


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

Comments (29)

  1. Jason says:

    <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

  2. StingK says:

    Hasn’t the target attribute been deprecated?

  3. JosephCooney says:

    IIRR turning smartnavigation ON on the aspx that appears in the modal dialog window also gets around this problem. YMMV.

  4. Elizabeth Ahola says:


    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


    arrModal = window.showModalDialog

    ("popup.asp",, _



    msgbox arrmodal

    in my popup window I have.


    window.returnvalue = "HERE I BE"


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

    any ideas? It seems so straight forward.

  5. Vittorio says:

    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.

  6. brendan says:

    window.returnvalue = "HERE I BE"

    should be

    window.returnValue = "HERE I BE"

  7. Chris Moutray says:

    thanks this fix really got me out of a jam …

  8. Dominique says:


    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..

  9. dwwe says:


  10. Thanks a lot !

    I used solution with <base.. /> and i works great.


  11. <center><b>you</b> says:


  12. ashwini says:

    does the <base target="_self"> work with modal .jsp files too…i tried it ..doesn’t work

  13. 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:


    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.

  14. Davide Senatore says:

    Great tip!

    The <base target="_self"> part works great for me!

    Thank you very much!


  15. sundar says:

    <base target="_self"> its working in first level of popup .. but am using second level its working in Firefox

    kindly do the needful.


Skip to main content