public static void ClearAllControls(Control PageObject)
{
foreach (Control ctrControl in PageObject.Controls)
{
if (object.ReferenceEquals(ctrControl.GetType(), typeof(TextBox)))
((TextBox)ctrControl).Text = string.Empty;
if (object.ReferenceEquals(ctrControl.GetType(), typeof(DropDownList)))
((DropDownList)ctrControl).SelectedIndex = -1;
ClearAllControls(ctrControl);
}
}
Call Controlprocedure using below codeClearAllControls(this);Note in the above code I have only involved TextBox and DropDownList Controls, likewise you can use your own.
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in)



0 comments:
Post a Comment