-
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
-
Re: Checkbox
Set the checkbox's autopostback property to true.
-
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.