I wanna call this jquery function in ASP.NET on button click event
var doRedirect = function() { location.href=\'http://www.example.com\' };
$(\"#button1\")
If your jQuery is inline, you can do the following:
var doRedirect = function() { location.href='http://www.example.com' };
$("#<%=button1.ClientId%>").click(function() {
$("#<%=label1.ClientId%>").show();
window.setTimeout("$('#<%=label1.ClientId%>').fadeOut('slow', doRedirect)", 10000);
});
If it isn't inline (i.e. in a file), you will need to get the client control Id's you want to use in a different way, for example wrapping them in a div
with an ID and selecting them through the div
:
<div id="myId">
<asp:Label runat="server" id="label1" />
<asp:Button runat="server" id="button1" />
</div>
var doRedirect = function() { location.href='http://www.example.com' };
$("#myId input").click(function() {
$("#myId span").show();
window.setTimeout("$('#myId span').fadeOut('slow', doRedirect)", 10000);
});
Note that I am using the output HTML element types as the descendant in the jQuery selector.