Clear all TextBox values

protected void ClearControl(Control Ctrl)//passing the control
{
foreach (Control eachCtrl in Ctrl.Controls)//loop taking each controls
{
if (eachCtrl.Controls.Count > 0)
ClearControl(eachCtrl);
else if (eachCtrl is TextBox)
((TextBox)eachCtrl).Text = null;
}
}

To call the method like this:

ClearControl(this);

1 comments :

This comment has been removed by a blog administrator.

Post a Comment