Sunday, January 20, 2008

Update Panel ,Default Button and FireFox


ASP.Net 2.0 comes up with a new concept called "Default Button" which is one button on the form will work as default button. Whenever we press the enter button default button will be called.

As for example: In a text box after typing you press enter your default button's event will be fired.

However, the one thing that was bothering me with the Default Button is it worked like a charm in IE. In Firefox, it behaved like the weirdly. The problem wasn't that it didn't do a postback. That it did. What it didn't do was hit the server side event (the button click event).
When you are selected in any textbox and you press enter, IE will submit this and hit the button click even. However with FireFox, it will only submit - not call the onclick event.

To solve this add: UseSubmitBehavior="False" to your submit button. Now you can press enter whenever you want in your form and it will do the proper submit regardless of IE or Firefox.

Enjoy..
Happy Programming…

2 comments:

Anonymous said...

Great aticle sir.
-Karishma Shah.Ahmedabad.

Virendra Dugar said...

Thanks Karishma...

back to top