How to disable checkboxes according to textbox text !

vb.net , asp.net , csharp Ni Dilli, India
  • 8 years ago

    i want to disable checkboxes according to textbox text

    For example --- if i enter 1,4 in textbox then checkbox1 and checkbox4 will be disabled and even after that when i type 2,3 in textbox then checkbox2 and checkbox3 will be disabled and checkbox1 and checkbox4 will be enabled again ...

    Remember : i wanna use this coding with unlimited no. of checkboxes...

    How to do this ?

    The code mentioned below can checked according to textbox text --but i want to disabled ony not checked ....

    Protected Sub TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles MyTextBox.TextChanged

    Dim separator As Char = ","c Dim allIIDs As New List(Of String)

    If MyTextBox.Text.Length <> 0 Then

    For Each strNum As String In MyTextBox.Text.Split(separator)

    Dim num As Int32 If Int32.TryParse(strNum, num) Then allIIDs.Add(strNum)

    End If

    Next

    End If allIIDs.Sort() For Each control As Control In UpdatePanel1.Controls

    If TypeOf control Is CheckBox Then Dim chk As CheckBox = DirectCast(control, CheckBox) chk.Checked = allIIDs.BinarySearch(chk.Text) > -1

    End If

    Next End Sub

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.” - Jon Ribbens