Refresh controls on Panel in webform?

G

Guest

How do you refresh the controls on a panel?

I've got a VB webform which contains a panel. On that panel is a
checkbox and a textbox. I'd like the textbox to appear when the
checkbox is checked and disappear when the checkbox is unchecked.

My code is:

Private Sub checkBox1_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles checkBox1.CheckedChanged
If checkBox1.Checked Then
textBox1.visible=False
else
textBox1.visible=True
end if
End Sub

The CheckChanged routine is being called when I check/uncheck the
checkbox. However, The TextBox doesn't disappear. The page needs to
be refreshed, but there doesn't seem to be anything like
Panel1.Refresh() or textBox.Refresh()
 
G

Guest

Probably the checkbox control is not set to autopostback.
Or it can happen to be set on autopostback but he lost his attached event,
and you can look in properties events tag to see if the checkbox has the
event attached.

If you say that the event CheckChange is called when you check/uncheck and
your texbox doesn't dissapear try to search in your page some other possible
setting of textbox1 visibility.

And your code should be like this to see the textbox1 when your checkbox si
checked.
textBox1.visible = checkBox1.Checked;

Cheers
 
C

Cor Ligthert

NoSpam,

I made a panel and on that a checkbox and a textbox.

With this code the textbox was not on the panel when the checkbox was
checked (I assume that you have set that autopostback as well).


\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
CheckBox1.AutoPostBack = True
End Sub
Private Sub checkBox1_CheckedChanged(ByVal _
sender As System.Object, ByVal e As System.EventArgs) _
Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
TextBox1.Visible = False
Else
TextBox1.Visible = True
End If
End Sub
///
I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top