Twisted Whisper
Twisted Whisper

Reputation: 1196

asp.net - pressing ENTER in a textbox and form submits

it's a simple question and yet i couldn't figure how this works. I created an aspx page without any master page. Put one text box on the form. then use Internet Explorer 8 and visit that page. typed something and hit ENTER on the keyboard. The form submits (judging by that page being refreshed). I didn't even put any buttons on the form. Just the textbox. What triggers the postback?

I further added one < asp:Button > next to the textbox and wired the button to see if it's been clicked. i repeat the same thing, typed something in the textbox and hit ENTER on the keyboard. The form submitted but the button wasn't click. What's happening? How the postback is triggered if it's not from the button?

This is happening in Mozila Firefox too except that when i added a button on the page, the button will be hit when ENTER on the keyboard is pressed.

Can anyone shed some light as to why the button i added didn't respond to the ENTER on the keyboard in IE8?

Thank you.

Upvotes: 2

Views: 4400

Answers (1)

Louis Waweru
Louis Waweru

Reputation: 3672

IE8 wants you to assign the postback to a button.

You can assign the <form> a default button, or you can wrap the textbox and button in an <asp:Panel> and assign the panel a default button.

Upvotes: 2

Related Questions