Dotnet Tutorials ,Codings & Examples: Clear all TextBox values <h1 class='display-2'> Clear all TextBox values ~ Dotnet Tutorials ,Codings & Examples</h1>

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