Question

I've been chasing this one around for a couple of days and it's starting to drive me a bit batty.

I have a text box on a Gridview which I'm allowing some data to be edited. When the enter key is hit, the TextChanged event happens, like I'd expect, but then it also fires the OnClick event of a button on the form.

I tried removing the button and it just moves to the next button on the form, so there's something about this that's making it think the enter key is pressing the button.

I've tried to Google it, but I'm not seeing much. I tried searching here, but it seems to be unusual enough that my search terms aren't catching it. Any help or suggestions would be most welcome.

Was it helpful?

Solution

Try setting the UseSubmitBehavior="False" on the buttons on your page.

OTHER TIPS

Change the AutoPostBack property of the textbox to true. By doing this you don't have to bother about any button's on submit behaviour also.

txtbox.AutoPostBack = true;

Your buttons have properties called IsCancel and IsDefault. If you disable them it will solve your issue.

Those properties allow a button to be treated as the default action for clicking the enter and escape keys.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top