How to clear all the textbox/groupbox on single click

Samirbhogayta
Posted by Samirbhogayta under ASP.NET category on | Points: 40 | Views : 1919
public void ClearTextBox(Form f)
{
for (int i = 0; i < f.Controls.Count; i++)
{
if (f.Controls[i] is TextBox)
{
f.Controls[i].Text = "";
}
else if (f.Controls[i] is GroupBox)
{
for (int j = 0; j < f.Controls[i].Controls.Count; j++)
{
if (f.Controls[i].Controls[j] is TextBox)
{
f.Controls[i].Controls[j].Text = "";
}
}
}
}
}

//How to call this function(Into the Submit Button)
Make a object from the Program.cs file.
object.ClearTextBox(this);
//After submit query

Comments or Responses

Login to post response