Problem
From my reading, here and elsewhere, obviously, the jQuery user interface (after the init dialog) moves your dialog element (along with its contents) outside the <form element and attaches it to the <body . The speculation is that the body is always present when the form is absent, and there may be some z-order advantages when using IE.
The problem is that all ASP.NET controls are required by Microsoft to be in the <form on the page to participate in the postback and work correctly, regardless of whether they are the actual HTML controls.
Solution (jQuery 1.4 +) *: programmatically move the dialog box inside the HTML form:
(There are other answers similar to this. This is the shortest I've seen taking only one line of code and not requiring changing the jQuery source code.)
With jQuery UI 1.8.7 (Stable, for jQuery 1.3.2+) I had success when ASP.NET controls supported PostBack behavior using the following "trick" derived from this forum thread :
// As is customary, call $mydialog.dialog(..) to initialize it. // Init all your dialog boxes before continuing. // After init, TYPE THIS LINE to move all dialog boxes back into the form element $('.ui-dialog').detach().appendTo('form');
To use only one fix dialog box, use this line instead:
$mydialog.closest('.ui-dialog').detach().appendTo('form');
where $ mydialog is a link to your dialog element using the jQuery -eg $('#mydiv') selector.
The reason the .ui-dialog class is used is because the jQuery user interface wraps your dialog element in an external div that has a ui type name for the class name, which is always in the outermost dialog element and is unique among all other names classes used throughout the dialog. This means that your actual dialogue is built not only for the html element that you specified to it, and you need to influence the entire dialogue.
After the init dialog, jQuery moves the constructed dialog outside the HTML form.
By inserting this line, you move everything back to the form, making ASP.NET happy.
detach The jQuery method cuts it out of the DOM, but supports all jQuery events and related data.
(* Since detach was introduced with jQuery 1.4, this solution is limited to this version and above. I heard that older versions of jQuery can have limited success using the clone and delete instead, although I have not tried this.)
appendTo The jQuery method inserts it into an html form.
This is what I understand. Hope this helps someone else.