disable checkbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • feninazman
    New Member
    • Jun 2007
    • 5

    #1

    disable checkbox

    hi ;)
    i'm doing my intern now.this is my 1st time using ASP.NET web matrix with VB.NET language...
    i need help in disabling my checkboxes.

    i have 4 checkboxes, let say "air" "water" "ice" "snow"
    if i check "air", i want all other 3 checkboxes to be disabled.

    it's something like a objective answer sheet but i'm asked to do it with checkbox not option button..

    help me please...thanx loads...

    ;)
  • vanc
    Recognized Expert New Member
    • Mar 2007
    • 211

    #2
    Originally posted by feninazman
    hi ;)
    i'm doing my intern now.this is my 1st time using ASP.NET web matrix with VB.NET language...
    i need help in disabling my checkboxes.

    i have 4 checkboxes, let say "air" "water" "ice" "snow"
    if i check "air", i want all other 3 checkboxes to be disabled.

    it's something like a objective answer sheet but i'm asked to do it with checkbox not option button..

    help me please...thanx loads...

    ;)
    You can write an event for checkbox's Checked. If the checkbox's Checked = true then you set the others's Enable value to False.

    Cheers.

    Comment

    • feninazman
      New Member
      • Jun 2007
      • 5

      #3
      this is wat i did,there are no error but my other three checkboxes which are "water" "ice" "snow" are still not disabled...and i can't use 'chkwater.Value ' cuz value is not a member...i seriously am blank rite now :(
      [code=vbnet]
      Private Sub chkair_Click(se nder As Object, e As System.EventArg s)
      If chkair.Checked = True Then
      chkwater.Enable d = False
      chkice.Enabled = False
      chksnow.Enabled = False
      End If
      End Sub
      [/code]
      but i totally appreciate ur tip ;) thanx loads...

      Comment

      • rhepsi
        New Member
        • Apr 2007
        • 111

        #4
        Originally posted by feninazman
        this is wat i did,there are no error but my other three checkboxes which are "water" "ice" "snow" are still not disabled...and i can't use 'chkwater.Value ' cuz value is not a member...i seriously am blank rite now :(

        Private Sub chkair_Click(se nder As Object, e As System.EventArg s)
        If chkair.Checked = True Then
        chkwater.Enable d = False
        chkice.Enabled = False
        chksnow.Enabled = False
        End If
        End Sub

        but i totally appreciate ur tip ;) thanx loads...


        Hey Y dont u write the same code for:

        CheckBox1_Check StateChanged event.........

        Code:
         (vb)
        Private Sub CheckBox1_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckStateChanged
         
                If CheckBox1.Checked = True Then
        
                    CheckBox2.Enabled = False
                    CheckBox3.Enabled = False
                    CheckBox4.Enabled = False
        
                Else
        
                    CheckBox2.Enabled = True
                    CheckBox3.Enabled = True
                    CheckBox4.Enabled = True
        
                End If
            End Sub

        Hope it'll work.... give a try...
        Last edited by rhepsi; Jun 13 '07, 12:24 PM. Reason: More details

        Comment

        • vanc
          Recognized Expert New Member
          • Mar 2007
          • 211

          #5
          Originally posted by feninazman
          this is wat i did,there are no error but my other three checkboxes which are "water" "ice" "snow" are still not disabled...and i can't use 'chkwater.Value ' cuz value is not a member...i seriously am blank rite now :(
          [code=vbnet]
          Private Sub chkair_Click(se nder As Object, e As System.EventArg s)
          If chkair.Checked = True Then
          chkwater.Enable d = False
          chkice.Enabled = False
          chksnow.Enabled = False
          End If
          End Sub
          [/code]
          but i totally appreciate ur tip ;) thanx loads...
          In this sense, I guess you didn't add this Click event correctly. It means the event handle of the "chkair" for Click event is not associate with the handle. You should double click on "chkair" checkbox and see where it will go, if it comes to the right piece of code, then yell at me.

          cheers.

          Comment

          • rhepsi
            New Member
            • Apr 2007
            • 111

            #6
            Originally posted by vanc
            In this sense, I guess you didn't add this Click event correctly. It means the event handle of the "chkair" for Click event is not associate with the handle. You should double click on "chkair" checkbox and see where it will go, if it comes to the right piece of code, then yell at me.

            cheers.

            Now even at the click event itz working fine...

            [code.vb]

            Private Sub CheckBox1_Click (ByVal sender As Object, ByVal e As System.EventArg s) Handles CheckBox1.Click
            If CheckBox1.Check ed = True Then

            CheckBox2.Enabl ed = False
            CheckBox3.Enabl ed = False
            CheckBox4.Enabl ed = False

            Else
            CheckBox2.Enabl ed = True
            CheckBox3.Enabl ed = True
            CheckBox4.Enabl ed = True
            End If
            End Sub
            End Class

            [/code]

            CHEERS
            Hepsi.

            Comment

            • feninazman
              New Member
              • Jun 2007
              • 5

              #7
              hye guys :)

              i've tried everything...bu t its still the same...its ok ;) my supervisor told me to change it using drop down list...so...new task coming up...

              thanx nyway ya!!heheee...

              <ginger>

              Comment

              Working...