views:

41

answers:

2

I have an ASP.NET application that also uses jQuery for modal pop-ups. If I put an ASP button (or image button) within the DIV for the jQuery modal, the "OnClick" event does not fire.

How can I fix this?

+2  A: 

When you create the dialog, you need to move it a bit for ASP.Net, like this:

$(".class").dialog({ 
  //options
}).parent().appendTo("form");

By default the .dialog() moves the content to just before </body> which most importantly is outside the <form></form>, so elements within it won't be included in the POST (or GET) to the server. If you manually move it like I have above, it'll resolve this issue.

Nick Craver
Pretty quick there Nick! :)
Marko
Great answer and it worked - thanx!
Jim Beam
+1  A: 

By default, jQuery places the modal OUTSIDE of the asp.net <form> element.

You can easily append it to the form like:

$("#your-modal").parent().appendTo("form:first");

And this should fix your problems. It's a common problem with jQuery/ASP.NET.

Enjoy

Marko