Showmodaldialog question

J

John

Hi all,

My web app makes use of the ShowModalDialog in a couple of places. In
certain instances, the user may click on a "Cancel" image button (there is
no code-behind for this) at which point a Javascript runs which does a
window.close()

The problem is that the parent page still posts to the server when there is
clearly no need to. How can I prevent the parent from posting to the server?

Regards
John.
 
B

Bruce Barker

change the onclick routine to "window.close;return false;"

-- bruce (sqlwork.com)
 
J

John

Bruce,

Thanks for your quick response but I'm still having the same problem (i.e.
the page is still posting back after a window.close; return false;).

The script in my parent page is as follows:
window.showModalDialog('Lookup_Cust.aspx' ,'Customer Lookup','dialogHeight:
470px; dialogWidth: 700px; edge: Raised; center: Yes; help: No; resizable:
No; status: No; unadorned: No; scroll: No');

Even if I put 'return false;' after the showModalDialog method, the page
still posts to the server.

Any other ideas as an unnecessary post seems so, well - unnecessary?

Regards
John.
 
E

Eliyahu Goldin

John,

You need to set window.returnValue property in the dialog before calling
window.close(). The parent will get it as a return value of the
showModalDialog call. In returnValue you can pass any object. It may be as
simple as true or false. Preset it to false on the dialog's onload event and
change it to true when "Save" or "Ok" or whatever else positive is clicked.
In this way you protect yourself against closing the dialog with clicking x
in the right top corner.

Eliyahu
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top