We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

In ASP.NET we can restrict carriage return in Textbox control by using the following sample code in design level of the application, which is using ASCII value for the enter key.

Its check each character’s ASCII value entered into the textbox, so when the enter key is pressed its also check the ASCII value and then it avoid to insert the carriage return value to the textbox. So we can avoid to insert Carriage Return into the textbox having “ Multiline” TextMode property or in TextArea control.

<asp:TextBox ID="txtComments" Height="150" Columns="200" TextMode="multiline"  MaxLength="4000" runat="server" onkeydown =  "return (event.keyCode!=13);" />

Note: ASCII value for Enter Key is 13.


Related Tags:

ASP.NET

Author: Rasmita Mohanty

top

ASP.NET

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login