Pages

Friday, January 23, 2009

ASP.NET 2.0 Multiline TextBox submits on enter in Firefox

I'm sure I've run into this issue before. If a form contains a asp:TextBox with TextMode="MultiLine" and you press enter in the textbox to create a new line the entire form gets submitted to the server in Firefox.

In my case Firebug revealed that the textarea was nested in a asp:Panel where onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl03_ctl05_btnSubmit')"

A little Googling on FireDefaultButton reminded me that its implementation is IE specific. The following article shows how to register a client script include that will update the function.