Wednesday, November 23, 2005

openModalDialog and form.submit (ie. a postback)

Faced a problem today regarding the use of window.openModalDialog instead of window.open.

Those damn users (well... THE user... a quite attractive one at that, but still a 'damn user') insisted on clicking buttons on a 'parent' web form while a 'child' form was open. The child form was used for selecting keywords relevant to the record inthe parent form.

Simple solution thinketh thine simple mind... Use openModalDialog instead of just open! Thus presents the first problem. window.opener no longer references the browser window that opened the web dialog. The solution to this is to pass the window object in as an argument to the openModalDialog method like so: window.openModalDialog('dialog.htm', window); This argument is then accessible through the window.dialogArgument property, in my case being used like so: window.dialogArgument.__doPostBack('');

This, however, didn't work on the first attempt. This script is being rendered from a button click event on the server. Each time the button was being clicked, a new, non modal window would open, and of course the dialogArgument was not set in this new window.

After a while of beating my head against a brick wall, I discovered that the new window was being opened as a result of the postback's form.submit and this can be worked around by adding the following tag between the page's tags: Thanks Rohan Thomas! http://www.dotnetjunkies.com/WebLog/rohanthomas/archive/2005/07/19/131357.aspx Bargain, now back to reading http://www.neopoleon.com/...

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

<< Home