I'll explain this more generally to help googlers of the future.
If you view the source of the page, you may straight away slap your forehead and say "of course!"
When you create a dialog with jQuery UI the element you create the dialog out of comes out of the <form>
and into the root of the <body>
element. That's just how jQuery UI's dialog works.
The code behind the .aspx
page is dependent on the form, anything outside the form cannot trigger the postback and therefore no code behind is run on any events that depend on elements outside the form.
The fix for this is thankfully quite simple :). After you create the dialog, simply append it to the <form>
.
You have rightly tried to do that in your code, however the selector you've used $("form1")
is looking for a <form1>
type element - which doesn't exist.
You can fix it with this code: .parent().appendTo("form");
although to ensure you get the first form element only you can use .parent().appendTo("form:first");
.
If form1
is the id of the form element you want to append to, then you would of course use $("#form1")
.