i have 5 checkboxes in my vb.net webform !
i have 5 checkboxes in my vb.net webform i want when two checkboxes are already checked on page load then say checkbox1 and checkbox2 开发者_运维知识库will be checked in page load event .... then when i check checkbox3 and checkbox4 then in textbox it will appear as 3,4 by ignoring 1,2 ..
I wanna do it using vb.net ...
I find your question slightly unclear so I might be misunderstanding.
It sounds like all you'll need to do is to store somewhere what checkboxes were checked during the page load event and then when you check some other checkboxes, you just ignore the ones that were already checked.
So in your page load, have something like (all code is just an example to show the structure and will probably not compile):
Dim preChecked As New List(Of CheckBox)
For Each ctrl As Control In page1.Controls
If TypeOf ctrl Is CheckBox Then
Dim chk As CheckBox = CType(ctrl, CheckBox)
If chk.Checked Then
preChecked.Add(chk)
End IF
End If
Next
Then in your other code you just have something like:
For Each ctrl As Control In page1.Controls
If TypeOf ctrl Is CheckBox Then
Dim chk As CheckBox = CType(ctrl, CheckBox)
If Not preChecked.Contains(chk) Then
If chk.Checked Then
' chk is checked but wasn't checked in the page load so show that in the textbox
End If
End If
End If
Next
精彩评论