Public Sub ResetControl(ByVal mypage As Page) Dim myForm As Control = mypage.FindControl("Form") For Each ctrl As Control In myForm.Controls 'Clears TextBox If TypeOf ctrl Is System.Web.UI.WebControls.TextBox Then TryCast(ctrl, TextBox).Text = String.Empty End If 'Clears DropDown Selection If TypeOf ctrl Is System.Web.UI.WebControls.DropDownList Then TryCast(ctrl, DropDownList).ClearSelection() End If 'Clears ListBox Selection If TypeOf ctrl Is System.Web.UI.WebControls.ListBox Then TryCast(ctrl, ListBox).ClearSelection() End If 'Clears CheckBox Selection If TypeOf ctrl Is System.Web.UI.WebControls.CheckBox Then TryCast(ctrl, CheckBox).Checked = False End If 'Clears RadioButton Selection If TypeOf ctrl Is System.Web.UI.WebControls.RadioButtonList Then TryCast(ctrl, RadioButtonList).ClearSelection() End If 'Clears CheckBox Selection If TypeOf ctrl Is System.Web.UI.WebControls.CheckBoxList Then TryCast(ctrl, CheckBoxList).ClearSelection() End If If TypeOf ctrl Is System.Web.UI.WebControls.GridView Then TryCast(ctrl, GridView).Columns.Clear() End If Next End Sub
Protected Sub btnSaveReq_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveReq.Click ' TODO: Add your save code here ResetControl(Me.Page) end sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)