Click here to Skip to main content
16,021,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am beginer for jquery
i wrote a JQuery code on asp button as follows

XML
<script src="JQuery.js" type="text/javascript"></script>
    <script type="text/javascript">
         $(document).ready(function(){
              $("#btnInsert").click(function(){
                    alert("Execute");
              });
         });
    </script>


but my page is getting postback

How can i execute that code without postback?
Posted

If your button #btnInsert is an Asp.Net button control, select the button in the designer and look at the properties

Make sure UseSubmitBehavior is set to False

Alternatively, you can just use a 'standard' html button here if you just want to execute client script.
 
Share this answer
 
You need to use event.preventDefault
Look here: jQuery knowledgebase: event.preventDefault()[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900