开发者

jQuery with C# doesn't fire onclick event

I have an ASP.NET application that also u开发者_Python百科ses 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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜