Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use many text box in one gridview and edit update it in gridview. Have one button out site grid view and when i press enter at time of editing text box that button's clickevent fire which i don't want. Can anyone tell that how do i prevent that.
Posted

Set
UseSubmitBehavior = "false"
for the button.
 
Share this answer
 
Comments
jaideepsinh 27-Jun-14 5:45am    
I used this it's not triggering button click event but it will refresh page and clear text box value.
Set the button's UseSubmitBehavior[^] to false
 
Share this answer
 
Comments
jaideepsinh 27-Jun-14 5:45am    
I used this it's not triggering button click event but it will refresh page and clear text box value.
I use following java script solve this:


JavaScript
<script language="javascript" type="text/javascript">
        function DisableTextboxPostback() {
            $(':text').bind('keydown', function (e) {
                if (e.keyCode == 13) {
                    e.preventDefault();
                    return false;
                }
                else
                    return true;

            });
        }

  function onBodyLoad() {
        DisableTextboxPostback();
  }
    </script>


Make javascript function to prevent postback and call that function on bodyload that way page will not to postback.
 
Share this answer
 
v2

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