This is probably not a Telerik problem, but I am hoping that someone in here can help me with this. I am using the RadPanelBar as a wizard for creating and managing users. When a user selects to create a new user, I need to clear out all all the controls' values in each of the panels. So I wrote a recursive function to do it. It works, but for some reason I lose object references to some things totally unrelated to the controls I have just recursed through. I also lose the linked events that worked before I ran this function. Attached is my code that I run.
Private Sub ClearAllFields(Optional ByRef ParentControl As Control = Nothing) |
If ParentControl Is Nothing Then |
For Each oPanel As RadPanelItem In rpbAccountAdmin.Items |
ClearAllFields(oPanel.Items(0)) |
Next |
Else |
For Each oControl As Control In ParentControl.Controls |
If oControl.HasControls Then |
ClearAllFields(oControl) |
End If |
If TypeOf (oControl) Is RadTextBox Then |
CType(oControl, RadTextBox).Text = "" |
ElseIf TypeOf (oControl) Is RadComboBox Then |
CType(oControl, RadComboBox).SelectedIndex = -1 |
ElseIf TypeOf (oControl) Is TextBox Then |
CType(oControl, TextBox).Text = "" |
ElseIf TypeOf (oControl) Is DropDownList Then |
CType(oControl, DropDownList).SelectedIndex = -1 |
ElseIf TypeOf (oControl) Is CheckBox Then |
Dim oCheckBox As CheckBox = CType(oControl, CheckBox) |
Select Case oCheckBox.ID |
Case "chkShowImages" |
oCheckBox.Checked = True |
Case Else |
oCheckBox.Checked = False |
End Select |
End If |
Next |
End If |
End Sub |