Como limpar todos controles input de uma página ASP.NET

Limpar todos os controles do tipo input.

Limpando todos os controles do tipo input em uma página asp.net.

protected void Button1_Click(object sender, EventArgs e) { Control myForm; using (myForm = Page.FindControl("Form1")) { foreach (Control ctrl in myForm.Controls) { //Clears TextBox if (ctrl is TextBox) (ctrl as TextBox).Text = ""; //Clears DropDown Selection if (ctrl is DropDownList) (ctrl as DropDownList).ClearSelection(); //Clears ListBox Selection if (ctrl is ListBox) (ctrl as ListBox).ClearSelection(); //Clears CheckBox Selection if (ctrl is CheckBox) (ctrl as CheckBox).Checked = false; //Clears RadioButton Selection if (ctrl is RadioButtonList) (ctrl as RadioButtonList).ClearSelection(); //Clears CheckBox Selection if (ctrl is CheckBoxList) (ctrl as CheckBoxList).ClearSelection(); } } }

Ou

Respose.Write("Pagina.aspx");

[]´s   Fabio Galante Mans

fabio.galante@mans.com.br www.mans.com.br

Artigos relacionados