asp.net.ph

Skip Navigation Links

TextBox Control Syntax

ASP.NET Syntax   ASP.NET Syntax for Web Controls


The TextBox control generates single-line and multiline text boxes.

Declarative Syntax

For information on the individual members of this class, see TextBox in the class library.

Properties


Property Description
AutoPostBack true if client-side changes in the control automatically cause a postback to the server; false otherwise. The default is false.
Columns The width of the control in characters. This property differs from the Width, which sets the absolute width of the control independent of the character spacing.
MaxLength The maximum number of characters allowed within text box. This property has no effect unless the TextMode property is set to SingleLine or Password.
Rows Number of rows within the text box. This property has no effect unless the TextMode property is set to MultiLine.
Text The text that the user has entered into the box.
TextMode Indicates whether the text box is in single-line, multi-line, or password mode. Possible values are Single, MultiLine, and Password.
Wrap Indicates whether text should wrap around as users type text into a multiline control. This property has no effect unless the TextMode property is set to MultiLine.
Base properties The properties inherited from the base WebControl class.

Events


Event ( and parameters ) Description
onTextChanged ( Object sender, EventArgs e ) Raised on the server when the contents of the text box change. This event does not cause the Web Forms page to be posted to the server unless the AutoPostBack property is set to true.

The event argument object e has no properties.


Remarks

The TextBox control is an input control that lets the user enter text. By default, the TextMode property is set to SingleLine, which creates a text box with only one line. You can also set the property to MultiLine or Password. MultiLine creates a text box with more than one line. Password creates a single-line text box that masks the value entered by the user.

The display width of the text box is determined by its Columns property. If the text box is a multiline text box, the display height is determined by the Rows property.

Syntax Example

The following shows a sample declaration for a TextBox control in an .aspx file. The control is multiline with columns set to 30 characters and rows set to 5 lines. The method txtChangedHandler is designated to receive control when the onTextChanged event occurs. In this example, the page is immediately sent to the server once the event fires because autopostback is set to true.

<asp:textbox runat=server
   id="myTextBox"
   textmode = "MultiLine"
   backcolor = "ivory"
   columns=30 rows=5
   text = "The multiline textbox ... "
   onTextChanged = "txtChangedHandler" 
   autopostback />

 Show me 

See Also

TextBox Class   TextBox Web Server Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note