Click here to Skip to main content
15,886,648 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i enter the textbox on textchanged event the button click event automatically fire. how to avoid the button click event on press enter key on textbox.
Posted
Updated 29-May-14 21:27pm
v2
Comments
Sampath Lokuge 30-May-14 3:28am    
Can you put your code snippet ?
Awadhendra Tripathi 30-May-14 3:42am    
Can you please provide us your code...
becose we were not able to understand your point

1 solution

Hi,

You can use this method to check whether enter key is pressed or not.

private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Return)
    {
        textBlock1.Text = "You Entered: " + textBox1.Text;
    }
}


or you have to try client side scripts in this way on onkeypress.

function (event) {
        if (event.which == 13 || event.keyCode == 13) {
            //code to execute here
            return false;
        }
        return true;
    });


Implement it according to your need.

Good Luck
 
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