Public Sub ClearFields(ByVal parent As System.Web.UI.Control)
Dim c As Control
For Each c In parent.Controls
If c.GetType() Is GetType(TextBox) Then
'is it a textbox?
Dim t As TextBox = c
t.Text = ""
ElseIf c.GetType() Is GetType(HtmlControls.HtmlInputHidden) Then
'is it a hidden text?
Dim h As HtmlControls.HtmlInputHidden = c
h.Value = ""
ElseIf c.GetType() Is GetType(DropDownList) Then
'is it a dropdown list?
Dim d As DropDownList = c
d.ClearSelection()
ElseIf c.GetType() Is GetType(ListBox) Then
'is it a listbox?
Dim l As ListBox = c
l.ClearSelection()
ElseIf c.GetType() Is GetType(RadioButtonList) Then
'is it a radiobutton list?
Dim rl As RadioButtonList = c
rl.ClearSelection()
ElseIf c.GetType() Is GetType(CheckBox) Then
'is it a checkbox?
Dim chk As CheckBox = c
chk.Checked = False
ElseIf c.GetType() Is GetType(CheckBoxList) Then
'is it a checkbox list?
Dim cl As CheckBoxList = c
cl.ClearSelection()
End If
If c.HasControls Then
ClearFields(c)
End If
Next
End Sub




