Please visit our sponsors !
CheckBox Control
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>
|
Jump to: Top of Page
or HOME or
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
|