Skip Navigation LinksASP.Net 2.0 Training : ASP.Net Checkbox
Banner for ASP.Net 2.0 training classes in Visual Basic 2005 

Skip Navigation Links
Visit my other site:

certification training

Free Flash tutorials and training

Free Dreamweaver Video Tutorials

Free PHP Training

Visual Basic Windows Training




If you like this site please link to it


CheckBox

  • The CheckBox control is used to display a check box.

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)

Try this:

1

<script  runat="server">

2

   Sub Check(sender As Object, e As EventArgs)

3

     if check1.Checked then

4

          work.Text=home.Text

5

     else

6

          work.Text=""

7

     end if

8

   End Sub

9

</script>

10

<html>

11

<body>

12

<form runat="server">

13

<p>Home Phone:

14

<asp:TextBox id="home" runat="server" />

15

<br />

16

Work Phone:

17

<asp:TextBox id="work" runat="server" />

18

<asp:CheckBox id="check1" Text="Same as home phone" TextAlign="Right" AutoPostBack="True" OnCheckedChanged="Check" runat="server" />

19

</p>

20

</form>

21

</body>

22

</html>

Save as: Checkbox.aspx


Trty this is Visual Studio 2005
  • Open Visual Studio
  • Add a new webform
  • Name it checkbox.aspx
  • Click the Add button
  • Select the Design View
  • Add 2 labels and 2 textbox controls
  • Add a checkbox control

  • Change the text of the labels to:

Home Phone:
Work Phone:

  • Change the id property of the textboxes to:

Home
Work

  • Change the id of the checkbox to:

Check1

  • Change the text of the checkbox to:

Same as home phone

  • Change the textAlign property to right
  • Change AutoPostBack to true

               

  • Double-click the checkbox
  • Add this code:

        If Check1.Checked Then
            work.Text = home.Text
        Else
            work.Text = ""
        End If

  • Test it by pressing CTRL + F5


      ASP.Net 2.0 tutorials & training