ASP.NET TextBox 控件

定义和用法

TextBox 控件用于创建用户可输入文本的文本框。

属性

属性 描述 .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 complete description, please visit Web Control Standard Properties.

Control Standard Properties

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

For a complete description, please visitControl Standard Properties.

Example

Textbox
In this example, 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. This submit subroutine will output text to the Label control.
Textbox 2
In this example, 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. This submit subroutine will copy the content of the text box to the Label control.