Clear the Control Text using a Common Method
By James H
Some times we need to clear text of the Textboxes. This is common in both Web and Windows.
This is one of the common requirement we get in our projects. Text box
has a wonderful method called "Clear". This method is used
to clear the text in the Text box.I have given a simple example to explain this. I have implemenetd a common method to clear the Text of few Controls. One of that is Textbox.
void ClearInputs(ControlCollection ctrls)
{
foreach (Control ctrl in ctrls)
{
if (ctrl is TextBox)
((TextBox)ctrl).Text = string.Empty;
ClearInputs(ctrl.Controls);
}
}
Clear the Control Text using a Common Method (477 Views)