HOME

ASP.NET Tutorial
ASP.NET HOME
ASP.NET Intro
ASP.NET vs ASP
ASP.NET Install
ASP.NET Pages
ASP.NET Controls
ASP.NET Events

References
HTML Controls
Web Controls
Validation Controls
Download XMLSpy here
Please visit our sponsors !

CheckBox Control

Back

Definition and Usage

The CheckBox control is used to display a check box.


Properties

Property Description
AutoPostBack A Boolean value that specifies whether the form should be posted immediately after the Checked property has changed or not. Default is false
Checked A Boolean value that specifies whether the check box is checked or not
id A unique id for the control
OnCheckedChanged The name of the function to be executed when the Checked property has changed
runat Specifies that the control is a server control.  Must be set to "server"
Text The text next to the check box
TextAlign On which side of the check box the text should appear (right or left)

Example 1

In the following example we declare two TextBox controls and one CheckBox control in an .aspx file. Then we create an event handler for the CheckedChanged event to copy the contents of a text box containing the home phone of a customer into a text box that contains the work phone:

<script runat="server">
  Sub Check_Clicked(sender As Object, e As EventArgs) 
    if Check1.Checked then
      work.Text=home.Text
    else
      work.Text=""
    end if
  End Sub
</script>
<html>
<body>
<form runat="server">
<table>
<tr>
<td>Home Phone:</td>
<td><asp:TextBox id="home" runat="server"/></td>
</tr>
<tr>
<td>Work Phone:</td>
<td><asp:TextBox id="work" runat="server"/></td>
</tr>
<tr>
<td></td>
<td>
<asp:CheckBox id="Check1" AutoPostBack="True"
Text="Same as home phone" TextAlign="Right"
OnCheckedChanged="Check_Clicked" runat="server"/>
</td>
</tr>
</table>
</form>
</body>
</html>


Back

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISProtect
Password Protect
Your Web Pages



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search