ASP.NET CheckBox Control

Definition and Usage

The CheckBox control is used to display a checkbox

Property

Property Description .NET
AutoPostBack Specifies whether the form is immediately posted back to the server after the Checked property changes. The default is false. 1.0
CausesValidation Specifies whether validation is executed when the Button control is clicked 2.0
Checked Specifies whether the checkbox is checked 1.0
InputAttributes Collection of attribute names and values used by the Input element of the CheckBox control 2.0
LabelAttributes Collection of attribute names and values used by the Label element of the CheckBox control 2.0
runat Specifies that the control is a server control. It must be set to "server". 1.0
Text Text label associated with the CheckBox 1.0
TextAlign Text alignment for the text label associated with the CheckBox control (right or left) 1.0
ValidationGroup 在 CheckBox 控件回发到服务器时要进行验证的控件组。 2.0
OnCheckedChanged 当 Checked 属性被改变时,被执行函数的名称。  

Web 控件标准属性

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

如需完整描述,请访问 Web 控件标准属性.

控件标准属性

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

如需完整描述,请访问控件标准属性.

实例

Checkbox
I detta exempel har vi deklarerat två TextBox-kontroller och en CheckBox-kontroll i .aspx-filen. Därefter har vi skapat ett eventhanterare för CheckedChanged-incidenten och kopierat innehållet i textfältet för hemtelefon till textfältet för arbetstelefon.