Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
54 Points
19 Posts
Apr 14, 2012 11:13 AM|LINK
for asp.net button we have onclick event that will be write on the code behind file by using jquery we can easily stop event handler byusing event.preventDefault
By using javascript
we write
<script type="text/javascript"> function Javasciptfunc() { if(ourcondition) { return true; } else { return false; } } </script> <asp:Button id="btn1" runat="server" onclick="myeventhandler" onclientclick="return Javasciptfunc()"/>
if you want write more condition write
<script type="text/javascript"> function Javasciptfunc() { if(ourcondition) { //dont return anything } else { return false; } if(another condition) { return true; } else { return false; } } </script> <asp:Button id="btn1" runat="server" onclick="myeventhandler" onclientclick="return Javasciptfunc()"/>
thirumalesh
Member
54 Points
19 Posts
Event Prevention Using JavaScript
Apr 14, 2012 11:13 AM|LINK
for asp.net button we have onclick event that will be write on the code behind file by using jquery we can easily stop event handler byusing event.preventDefault
By using javascript
we write
<script type="text/javascript"> function Javasciptfunc() { if(ourcondition) { return true; } else { return false; } } </script> <asp:Button id="btn1" runat="server" onclick="myeventhandler" onclientclick="return Javasciptfunc()"/><script type="text/javascript"> function Javasciptfunc() { if(ourcondition) { //dont return anything } else { return false; } if(another condition) { return true; } else { return false; } } </script> <asp:Button id="btn1" runat="server" onclick="myeventhandler" onclientclick="return Javasciptfunc()"/>