0

ASP.NET seems to be generating its own onclick event for any buttons that are generated.

Looks like this

javascript:__doPostBack(

This is preventing jQuery from working correctly.

Does anyone know how to stop asp.net engine from doing this?

Many thanks

asked May 20, 2009 at 14:33

2 Answers 2

2

You just need to add a return false to your jquery code that handles the button.

$("myaspbutton").click(function(e){
 //your code
 return false;****
});
answered May 20, 2009 at 14:40

Comments

0
<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();
});
answered May 20, 2009 at 14:37

1 Comment

That doesn't work either. I've even tried e.defaultValue = false;

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.