javascript - cancel postback in linkbutton when binding to jquery click event -


i have linkbutton binding click event using jquery, page still posts no matter try...

according this should able use event.preventdefault

however nothing seems work , posts back, but alert

here example

 <asp:linkbutton runat="server" text="test" id="lnktest"></asp:linkbutton>  <script>      $(document).ready(function () {         var lnk = $('#<%=this.lnktest.clientid %>');         lnk.unbind('click.test').bind('click.test', function (event) { alert("click"); event.preventdefault(); event.stoppropagation(); return false; });     }); </script> 

update

okay after further investigation seems work expected when run in standalone page, using this script, , appears causing conflict..

that script moves href='javascript:... click handler, im guessing order handlers assigned may have it...

edit: i've tried reproducing without success. else in code differs this demo?


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -