Latest web development tutorials

ASP.NET TextBox control

Web Server Controls Web server control

Definition and Usage

TextBox control is used to create a user can enter text in the text box.


Attributes

属性 描述 .NET
AutoCompleteType 规定 TextBox 控件的 AutoComplete 行为。 2.0
AutoPostBack 布尔值,规定当内容改变时,控件是否自动回传到服务器。默认是 false。 1.0
CausesValidation 规定当 Postback 发生时,是否验证页面。 2.0
Columns textbox 的宽度。 1.0
MaxLength 在 textbox 中所允许的最大字符数。 1.0
ReadOnly 规定能否改变文本框中的文本。 1.0
Rows textbox 的高度(仅在 TextMode="Multiline" 时使用)。 1.0
runat 规定该控件是否是服务器控件。必须设置为 "server"。
TagKey
Text textbox 的内容。 1.0
TextMode 规定 TextBox 的行为模式(单行、多行或密码)。 1.0
ValidationGroup 当 Postback 发生时,被验证的控件组。
Wrap 布尔值,指示 textbox 的内容是否换行。 1.0
OnTextChanged 当 textbox 中的文本被更改时,被执行的函数的名称。

Web Control Standard Properties

AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, SkinID, Style, TabIndex, ToolTip, Width

For a full description, visit the Web Control Standard Attributes .

Control Standard Properties

AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Visible

For a full description, go to Control Standard Attributes .


Examples

Textbox
In this example, we declare a TextBox control in an .aspx file, a Button control, and a Label control. When the submit button is triggered, the submit subroutine. The submit subroutine will output text to the Label control.

Textbox 2
In this example, we declare a TextBox control in an .aspx file, a Button control, and a Label control. When the submit button is triggered, the submit subroutine. The content of the subroutine will submit a copy of the text box to the Label control.


Web Server Controls Web server control