Vittorio Bertocci

Scatter thoughts

ShowModalDialog

ShowModalDialog

  • Comments 29

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 :-)

  • fsda
  • dg
  • asodjsodjweodjwedwe
  • ssss
  • Thanks a lot !
    I used solution with <base.. /> and i works great.

    Tomas
  • <center><b>you</b>
  • does the <base target="_self"> work with modal .jsp files too...i tried it ..doesn't work
  • test
  • test
  • 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.




  • Great tip!
    The <base target="_self"> part works great for me!
    Thank you very much!

    Davide
  • The blogosphere saves my ass again
  • <base target="_self"> its working in first level of popup .. but am using second level its working in Firefox

    kindly do the needful.

    -sundar

Page 2 of 2 (29 items) 12
Leave a Comment
  • Please add 6 and 6 and type the answer here:
  • Post