Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Multiline TextBox causes postback in Firefox.

Modified: 2009/08/26 17:12 by Vincevanm - Categorized as: ASP.NET, Csharp
The problem:

We have a .NET form on a website with a ASP:Textbox control in multiline mode. Internet Explorer users can press enter in the field to start a new paragraph or line. Firefox users press enter and the form is submitted (postback).

The solution:

< asp : TextBox ID=" tbMessage" runat=" server" onkeypress=" event.cancelBubble=true;" TextMode=" MultiLine" CSSclass=" cFormInput-10" TabIndex=" 9" MaxLength=" 5000">< /asp:TextBox >

use the event.cancelBubble property in the "onkeypress" attribute so that the textbox doesn't launch an event.

 © Evident Interactive BV