ASP.NET seems to emit its own onclick event for any generated buttons.
Looks like this
JavaScript: __ doPostBack (
This prevents jQuery from working properly.
Does anyone know how to stop the asp.net engine from doing this?
Many thanks
You just need to add return false to the jquery code that handles the button.
$("myaspbutton").click(function(e){ //your code return false;**** });
<asp:Buttton runat="server" ID="myButton" Text="MyButton" OnClientClick="alert('hi');" />
Update: you can bind the click event dynamically:
$('#<%=myButton.ClientID%>').click(function(e) { //your code here e.preventDefault(); });