How to add a Javascript event handler using asp.net ajax
I am wondering how to add a Javascript event handler using asp.net ajax.
I need to add event handlers after ajax update because jQuery plugin to sort tables doesn't work and the onload
method to display a screen keyboard does not trigger as well.
Is there a way to do that?
Maybe I need to switch to some开发者_如何学Python other ajax library or/and try Asp.Net MVC to accomplish?
Your question is a little unclear. Anyway, if you are after to add an event handler to an element after partial update, check the following sample.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function() {
if (prm.get_isInAsyncPostBack) {
$addHandler($get("Button1"), "click", function() {
alert("This is a test...");
});
}
});
</script>
精彩评论