Results 1 to 3 of 3

Thread: Checkbox

  1. #1

    Thread Starter
    Lively Member achor's Avatar
    Join Date
    May 2006
    Location
    Porto
    Posts
    123

    Checkbox

    Hello all,

    Why this never occurs?

    Code:
     
    Protected Sub chkName_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkName.CheckedChanged
            If chkName.Checked = True Then
                txtName.Visible = True
            Else
                txtName.Visible = False
            End If
    End Sub
    The point is to click in the check box and depending on chkName 's value turn txtName's visibility on or off.

    But when I run my app, this never occurs. It was supose to run this code when I click in chkName

    Thanks, :P

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Checkbox

    Set the checkbox's autopostback property to true.

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Checkbox

    the code never runs because when the user clicks the checkbox, the page doesn't post back to the webserver to process that code.

    In the designer, select the checkbox, and from the properties window, set the AutoPostBack property to true. This will cause the page to submit to itself when you click the checkbox, and fire the page_load event, and then fire the code from your post above.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width