Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET TextBox Control

ASP.NET Web Forms - TextBox Control


The TextBox control is used to create a text box where users can enter text.


TextBox Control

The TextBox control is used to create a text box where users can enter text.

The features and properties of the TextBox control are listed on our WebForms Controls Reference Manual page。

The example below demonstrates some properties of the TextBox control that you may use:

Example

A basic TextBox:



A password TextBox:



A TextBox with text:



A multiline TextBox:



A TextBox with height:

runat="server" />



A TextBox with width:

Demo Example »


Add Script

When a form is submitted, the content and settings of the TextBox control may be modified by server scripts. The form can be submitted by clicking a button or when the user modifies the value of the TextBox control.

In the example below, we declare a TextBox control, a Button control, and a Label control in the .aspx file. When the submit button is triggered, the submit subroutine is executed. The submit subroutine writes a line of text into the Label control:

Example

Enter your name:

Demo Example »

In the example below, we declare a TextBox control and a Label control in the .aspx file. When you modify the value in the TextBox and click outside the TextBox (or press the Tab key), the change subroutine is executed. The change subroutine writes a line of text into the Label control:

Example

Enter your name:

text="Hello World!"

ontextchanged="change" autopostback="true"/>

Demo Example »