tomouse
Technical User
- Aug 30, 2010
- 50
I have a placeholder control on my page. When loading in data I add pairs of checkboxes and htmlanchor tags to this placeholder. The checkboxes allow users to select the anchors and remove them if they wish. The problem is that sometimes (seems to happen most consistently directly after the data has been brought back from the database) a checked checkbox is saying checked=false.
The is how I add the checkboxes and anchors to the placeholder control:
When user clicks a "Remove selected link(s)" button the following is called:
Usually this works, but sometimes I can load up the page, check a checkbox, click the Remove button and using the watch window I can see that all the checkboxes are reporting checked=false. And of course when this happens none of links are removed. Any ideas what could be causing this or how I could fix it?
The is how I add the checkboxes and anchors to the placeholder control:
Code:
Private Sub AddFileToList(ByVal sFilePath As String)
Dim cbFile As New CheckBox
Dim haFile As New HtmlAnchor
cbFile.checked = false
haFile.InnerText = sFilePath
haFile.Title = "Open file in new window"
haFile.Target = "_blank"
haFile.HRef = sServerPath & sFilePath
phLinkList.Controls.Add(cbFile)
phLinkList.Controls.Add(haFile)
End Sub
Code:
For iCount = phLinkList.Controls.Count - 1 To 0 Step -1
If TypeOf phLinkList.Controls(iCount) Is CheckBox Then
cBox = CType(phLinkList.Controls(iCount), CheckBox)
Debug.WriteLine(iCount.ToString & " - " & cBox.Checked)
If cBox.Checked = True Then
cAnchor = CType(phLinkList.Controls(iCount + 1), HtmlAnchor)
lstDelete.Add(cAnchor.InnerText)
phLinkList.Controls.Remove(phLinkList.Controls(iCount + 1))
phLinkList.Controls.Remove(phLinkList.Controls(iCount))
End If
End If
Next