CheckBox
CheckBox
The CheckBox Web server control gives us an option to select, yes/no or true/false. A checkbox is clicked to select and clicked again to deselect some option. When a checkbox is selected, a check (a tick mark) appears indicating a selection. The class hierarchy for this control is as follows:
Object
Control
WebControl
CheckBox
Properties::
1.AutoPostBack::Specifies whether the form should be posted immediately after the Checked property has changed or not. Default is false.
2.CausesValidation::Specifies if a page is validated when a Button control is clicked
3.Checked::Specifies whether the check box is checked or not 1.0
4.InputAttributes::Attribute names and values used for the Input element for the CheckBox control.
5.LabelAttributes::Attribute names and values used for the Label element for the CheckBox control
6.runat::Specifies that the control is a server control. Must be set to "server"
7.Text::The text next to the check box 1.0
8.TextAlign::On which side of the check box the text should appear (right or left)
9.ValidationGroup::Group of controls for which the Checkbox control causes validation when it posts back to the server 2.0
10.OnCheckedChanged::The name of the function to be executed when the Checked property has changed
CheckBox
***********************************************************************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckBox.aspx.cs" Inherits="_Default" %>
CheckBox Control
*********************************************************************
CS code when Button Clicked
*********************************************************************
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Show_Click(object sender, EventArgs e)
{
if(Men.Checked)
{
TextBox1.Text="Your Gender is:" +Men.Text;
}
if(Women.Checked)
{
TextBox1.Text="Your Gender is:" +Women.Text;
}
}
}