Postback not working in jQuery UI’s Dialog?

Today while working with the jQuery UI’s Dialog in an ASP.net Application, surprisingly none of the PostBacks were working inside the Dialog! Even I was stumbled when the button click was not caught in Debug Mode.

After a brief look at the generate code with Chrome Developer Tool, I saw jQuery is taking the Entire Dialog Content outside  of the <form runat=”server”> tag.  This made my PostBack no longer function as expected.

Luckily the fix was evenhandedly easy with jQuery itself. 🙂

Just moved the Dialog content back inside the <form runat=”server”> tag.

My Original Code:

$('#dialog1').dialog({
	autoOpen: false,
	width: 800,
	buttons: {}
});

The Code with Fix:

$('#dialog1').dialog({
	autoOpen: false,
	width: 800,
	buttons: {},
	open : function(type, data){
	    $(this).parent().appendTo("form");
	}
});

Only added:

open : function(type, data){
    $(this).parent().appendTo("form");
}

as Parameter and it worked the charm!!!

Advertisements

3 thoughts on “Postback not working in jQuery UI’s Dialog?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s