<script type="text/javascript">
function allclear()
{ //debugger
var elements=document.getElementsByTagName("INPUT");
for(i=0;i<elements.length;i++)
if(elements[i].type=="radio")
elements[i].checked=false;
for(i=0;i<elements.length;i++)
if(elements[i].type=="checkbox")
elements[i].checked=false;
for(i=0;i<elements.length;i++)
if (elements[i].type=="text")
elements[i].value="";
var elements1=document.getElementsByTagName("SELECT");
for(i=0;i<elements1.length;i++)
if(elements1[i].id!="" && elements1[i].id!=null)
elements1[i].selectedIndex=0;
}
</script>
---------------------------------------------------------------------------------------
private void ClearControls(Control c)
{
if (c.GetType() == typeof(System.Web.UI.WebControls.TextBox))
((TextBox)c).Text = "";
if (c.GetType() == typeof(System.Web.UI.WebControls.RadioButtonList))
{
RadioButtonList rbtl = (RadioButtonList)c;
for (int j = 0; j < rbtl.Items.Count; j++)
rbtl.Items[j].Selected = false;
}
if (c.GetType() == typeof(System.Web.UI.WebControls.DropDownList))
((DropDownList)c).SelectedIndex = 0;
if (c.GetType() == typeof(System.Web.UI.WebControls.RadioButton))
((RadioButton)c).Checked = false;
foreach (Control child in c.Controls)
ClearControls(child);
}
------------------------------------------------------------------------------------------------------------------------
private void DisableControls(Control c)
{
if ((c is TextBox) || (c is LinkButton) || (c is Button) || (c is CheckBox) || (c is CheckBoxList) || (c is RadioButtonList) || (c is DropDownList) || (c is Panel) || (c is ImageButton))
{
((WebControl)c).Enabled = false;
}
foreach (Control child in c.Controls)
DisableControls(child);
}
No comments:
Post a Comment