- HTML Checkbox Web Server Control
In ASP.NET environment,This article describes you how to work with HTML Checkbox
Control.In HTML environment, Checkbox is an object that represents a Checkbox in
an HTML form. The Checkbox control in a HTML form contains all instance of an <input
type="checkbox"> tag.
The primary mechanism of the checkbox control is to perform toggle operaiton. In
other words, Use the HtmlInputCheckBox control to allow the user to select a true
or false state. To determine whether the control is selected, use the Checked property
There are several functions available to access the HTML checkbox.some of its funtions
are as follows,
- document.getElementById()
- document.getElementByName()
checkbox Objects Properties
- id -Sets or returns the id of a checkbox
- form -Returns a reference to the form that contains the checkbox
- accessKey -Sets or returns the keyboard key to access a checkbox
- alt -Sets or returns an alternate text to display if a browser does not support
checkboxs
- disabled -Sets or returns whether or not a checkbox should be disabled
- tabIndex -Sets or returns the tab order for a checkbox
- name -Sets or returns the name of a checkbox
- type -Returns the type of form element a checkbox is
- checked -Sets or returns whether or not a checkbox should be checked
- defaultchecked - Returns the default value of the checked attribute
- value -Sets or returns the text that is displayed on the checkbox
- title -Sets or returns an element's advisory title
- lang -Sets or returns the language code for an element
- dir -Sets or returns the direction of text
- className -Sets or returns the class attribute of an element
checkbox Objects Methods
- blur() -Performs focus when leave from the control
- click() -Simulates a mouse-click on a checkbox
- focus() -Performs focus when enter into the control
The following code snippets explains you the HTML checkbox in the web form.
in .aspx.cs page,
-
protected void SubmitBtn_Click(object sender, EventArgs e)
{
if (chkapple.Checked)
{
// set code
}
if (chkorange.Checked)
{
// set code
}
if (chkbanana.Checked)
{
// set code
}
}
-
in .aspx page,
-
<body>
<form id="Form2" method=post runat=server>
Enter Interests:
<input id="chkapple" checked type=checkbox runat=server> apple
<input id="chkorange" type=checkbox runat=server> orange
<input id="chkbanana" type=checkbox runat="server"> banana
<input id="Button1" type=button value="Enter"
OnServerClick="SubmitBtn_Click" runat=server>
</form>
</body>
-
- Related Links
-
ae34e012-9072-43bd-8ab1-693d172e3968|0|.0