i have an if statement that neds to check if the control passed is a checkbox or a radio button
If TypeOf (Control) Is CheckBox Then
If count = 1 Then
text += Me.GetCheckBoxValueJQuerySyntax(Control.ClientID) & " + '~' + "
Else
text += Me.GetCheckBoxValueJQuerySyntax(Control.ClientID) & "'~' + "
End If
End If
If TypeOf (Control) Is RadioButton Then
If CType(Control, RadioButton).GroupName <> "" Then
If Not Me._GroupNameArrayList.Contains(CType(Control, RadioButton).GroupName) Then
Me._GroupNameArrayList.Add(CType(Control, RadioButton).GroupName)
If count = 1 Then
text += Me.GetRadioValueJQuerySyntax(Control.ClientID) & " + '~' + "
Else
text += Me.GetRadioValueJQuerySyntax(Control.ClientID) & "'~' + "
End If
End If
Else
If count = 1 Then
text += Me.GetRadioValueJQuerySyntax(Control.ClientID) & " + '~' + "
Else
text += Me.GetRadioValueJQuerySyntax(Control.ClientID) & "'~' + "
End If
End If
End If
This fails as the checkbox and redio button derive from the same class, so how would i check if the control is a checkbox or a radio button
You’re close;
RadioButtonderives fromCheckBox, so they’re both technicallyCheckBoxes. So, in this case, you can flip the statement around and useElse Ifto get the results you’re looking for.