(here BaseUtility is the class file).
BaseUtility.CS Page :
public static void PageControlsClear(Page currentPage)
{
List<Control> allControls = new List<Control>();
GetControlList<Control>(currentPage.Controls, allControls);
foreach (var childControl in allControls)
{
if (childControl.GetType() == typeof(TextBox))
((TextBox)childControl).Text = string.Empty;
if (childControl.GetType() == typeof(DropDownList))
((DropDownList)childControl).ClearSelection();
if (childControl.GetType() == typeof(CheckBox))
((CheckBox)childControl).Checked = false;
if (childControl.GetType() == typeof(CheckBoxList))
((CheckBoxList)childControl).ClearSelection();
}
}
public static void PageControlsClear(Page currentPage)
{
List<Control> allControls = new List<Control>();
GetControlList<Control>(currentPage.Controls, allControls);
foreach (var childControl in allControls)
{
if (childControl.GetType() == typeof(TextBox))
((TextBox)childControl).Text = string.Empty;
if (childControl.GetType() == typeof(DropDownList))
((DropDownList)childControl).ClearSelection();
if (childControl.GetType() == typeof(CheckBox))
((CheckBox)childControl).Checked = false;
if (childControl.GetType() == typeof(CheckBoxList))
((CheckBoxList)childControl).ClearSelection();
}
}
No comments:
Post a Comment
Comments