Refresh controls on Panel in webform?

Discussion in 'ASP .Net Web Controls' started by *no spam*, Oct 8, 2004.

  1. *no spam*

    *no spam* 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()
     
    *no spam*, Oct 8, 2004
    #1
    1. Advertising

  2. *no spam*

    Psycho 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
    "*no spam*" wrote:

    > 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()
    >
     
    Psycho, Oct 8, 2004
    #2
    1. Advertising

  3. *no spam*

    Cor Ligthert Guest

    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

    "*no spam*" <>

    > 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()
     
    Cor Ligthert, Oct 8, 2004
    #3
  4. *no spam*

    *no spam* Guest

    It turned out to be the autopostback setting. thx to all who replied!
     
    *no spam*, Oct 8, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. titof
    Replies:
    0
    Views:
    516
    titof
    Jul 24, 2003
  2. timmso
    Replies:
    1
    Views:
    501
    Alex Papadimoulis
    Dec 12, 2003
  3. *no spam*

    Refresh controls on Panel in webform?

    *no spam*, Oct 8, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,050
    *no spam*
    Oct 8, 2004
  4. =?Utf-8?B?bXN1aw==?=

    Using one webform to set a value on another webform

    =?Utf-8?B?bXN1aw==?=, Jul 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    471
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 12, 2006
  5. =?Utf-8?B?Vk1J?=

    Moving value from popup Webform to main Webform?

    =?Utf-8?B?Vk1J?=, Oct 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    581
    GroupReader
    Oct 9, 2006
Loading...

Share This Page