Results 1 to 1 of 1

Thread: checkbox not working? ## RESOLVED MYSELF :) ##

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2004
    Posts
    59

    checkbox not working? ## RESOLVED MYSELF :) ##

    hello

    I am trying to change the value of a label using 2 checkboxes.

    the label starts of with an emply string, if i click on the first checkbox, the label text should change to "hello" and if I click on the second check box the label should change to "bye"

    I want this to happen without having to click on another button (after selecting a checkbox) to update the label.

    I have the following code so far which does not work. please help:

    VB Code:
    1. Public Class WebForm1
    2.     Inherits System.Web.UI.Page
    3.     Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    4.     Protected WithEvents RadioButton2 As System.Web.UI.WebControls.RadioButton
    5.     Protected WithEvents RadioButton1 As System.Web.UI.WebControls.RadioButton
    6.  
    7. #Region " Web Form Designer Generated Code "
    8.  
    9.     'This call is required by the Web Form Designer.
    10.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    11.  
    12.     End Sub
    13.  
    14.     Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    15.         'CODEGEN: This method call is required by the Web Form Designer
    16.         'Do not modify it using the code editor.
    17.         InitializeComponent()
    18.     End Sub
    19.  
    20. #End Region
    21.  
    22.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    23.         'Put user code to initialize the page here
    24.     End Sub
    25.  
    26.     Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
    27.         If RadioButton1.Checked = True Then
    28.             Label1.Text = "hello"
    29.         End If
    30.     End Sub
    31.  
    32.     Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
    33.  
    34.         If RadioButton2.Checked = True Then
    35.             Label1.Text = "bye"
    36.         End If
    37.     End Sub
    38. End Class
    Last edited by narmi2; Jul 4th, 2004 at 10:35 AM.

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