Wednesday, November 23, 2005

openModalDialog and form.submit (ie. a postback)

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

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! Bargain, now back to reading

A Blog Eh?

So... It's been while, but I guess that just makes this so much more momentous. Worthy of the gods granting everlasting happiness, similar in grandeur to all the powers of the world banding together for a day of paintball to end all war by forever releasing their frustrations in the form of small, multi-coloured balls of water soluble paint aimed squarely at the arse (face?) of the nearest red-faced, mouth-foaming competitor... Wow... and I thought this was gonna be all boring and techie and stuff... Well, OK it may still be boring and stuff, but at least its not completely geeky stuff...