using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ClearTextBoxes(Panel1);
}
protected void ClearTextBoxes(Control control)
{
foreach (Control c in control.Controls)
{
if (c is TextBox)
((TextBox)c).Text = "";
if (c is CheckBox)
((CheckBox)c).Checked = false;
}
}
}
Related posts:
works great!
I put into a public utility class and made the class and method static.
Now can call from anywhere!
public static class Utilities
{
public static void ClearTextBoxes(Control control)//usage Utilities.ClearTextBoxes(pnlShipping);
{
foreach (Control c in control.Controls)
{
if (c is TextBox)
((TextBox)c).Text = string.Empty;
if (c is CheckBox)
((CheckBox)c).Checked = false;
}
}
}
//usage Utilities.ClearTextBoxes(pnlShipping);
how do you call a class to your program?