2.0 can't access control values when inside hidden div


I am using 2.0 and I have a chekc box list which is inside a jquery pop up box. I cannot access the values of the chekc box list in the code behind. It seems as if they are lost or empty even though some of the values are checked. I presume this is because they are in a hidden div on the client.

Is there anything I can do to fix this? I coudl do something on the client side to add the checkbox values to a hidden variable but I'd rather just be able to access them in the code behind

thanks a lot
Who is Participating?
guru_samiConnect With a Mentor Commented:
Putting it inside a hidden div shouldn't make a difference. May be something else is missing.
- What kind of popup is it?
- Are you sure you are not doing anything with the CBL in the pageLoad?

Here's a sample demo.
Can you access the checkobx list object in the code behind?

If no you need to declare that checkboxlist with the same ID as HTML in the code behind modlue.(declare as protected)
And may be sharing some code would help as well.
andiejeAuthor Commented:
Yes i can access the checkbox list in the code behind. The problem is that the selected items are not accessible. I iterate through these in a function but they are coming back as empty strings.

Public Function GetCommaSeparatedListOfGeofencesForSP(ByVal cblGeofences As CheckBoxList)
        Dim regList As String = String.Empty
        Dim getAll As Boolean = False

        For Each item As ListItem In cblGeofences.Items
            If item.Selected Or getAll = True Then
                If item.Value = "All" Then
                    getAll = True
                    If regList = String.Empty Then
                        regList = String.Format("{0}", item.Value)
                        regList = String.Format("{0},{1}", regList, item.Value)
                    End If
                End If

            End If

        Return regList
    End Function

Open in new window

I get a string error saying the index must be within the string suggesting the string is empty. If i take the checkbox list out of the hidden div everything is fine
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.