/////////////
Use NameSpace
1. using System.Web.UI;
2. using System.Web.UI.HtmlControls;
Use NameSpace
1. using System.Web.UI;
public static void Clear_Controls_Comman(Panel
ControlIDs)
{
foreach (Control
item in ControlIDs.Controls)
{
if (item is TextBox)
{
TextBox t = item as TextBox;
t.Text = "";
}
else if (item is CheckBox)
{
CheckBox t = item as CheckBox;
t.Checked = false;
}
else if (item is DropDownList)
{
DropDownList t = item as DropDownList;
t.ClearSelection();
if (t.Items.Count > 0)
{
t.SelectedIndex = 0;
}
}
else if (item is CheckBoxList)
{
CheckBoxList
t = item as CheckBoxList;
t.ClearSelection();
}
else if (item is RadioButton)
{
RadioButton t = item as RadioButton;
t.Checked = false;
}
else if (item is RadioButtonList)
{
RadioButtonList t = item as RadioButtonList;
t.ClearSelection();
}
else if (item is HtmlInputText)
{
HtmlInputText t = item as HtmlInputText;
t.Value = "";
}
else if (item is HtmlTextArea)
{
HtmlTextArea t = item as HtmlTextArea;
t.InnerText = "";
}
else if (item is HtmlInputCheckBox)
{
HtmlInputCheckBox t = item as HtmlInputCheckBox;
t.Checked = false;
}
}
}
No comments:
Post a Comment