Click here to Skip to main content
15,881,172 members
Articles / Web Development / HTML

JQuery.UI Dialog with ASP.NET empty post values

Rate me:
Please Sign up or sign in to vote.
4.75/5 (3 votes)
8 Jun 2009CPOL 26K   7   2
I ran into an issue using a jQuery.UI.Dialog control on an ASP.NET web form today. When defining a dialog, jQuery.UI takes the dialog and appends it right before the closing tag.

I ran into an issue using a jQuery.UI.Dialog control on an ASP.NET web form today. When defining a dialog, jQuery.UI takes the dialog and appends it right before the closing </body> tag. This is outside of the <form> tag causing any values you wanted from the form to be empty in your code-behind.

Here is the fix that worked for me:

$("#dialog").parent().appendTo("/html/body/form[0]");

This works great and the dialog now displays as expected, capturing the results in the code behind except I originally wanted the dialog wrapped in a UpdatePanel. In order to fix this issue, I created an empty div and appended the dialog content there:

$("#dialog").parent().appendTo("#dialog_target");

Not the results I expected. When the content refreshes, the dialog is messed up. The answer was to move the content panel inside of the dialog with the user control doing all the work!!!

This article was originally posted at http://www.trentjones.net?p=107

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Jelgab25-Feb-13 10:02
Jelgab25-Feb-13 10:02 
QuestionYour solution didn't work for me but lead me to one that did Pin
Justin Clarke13-Jun-12 5:12
Justin Clarke13-Jun-12 5:12 
http://stackoverflow.com/questions/568784/jquery-modal-form-dialog-postback-problems[^]

$("#myDiv").parent().appendTo($("form:first"));

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.