How to Clear the Textbox Text using C#?

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;
You can call this  method where ever you want to clear the Text from the Textbox.
For more information please click this link
Hope this would help the beginners. 


Popular posts from this blog

How to hide bootStrap popover when user click(s) outside the popover?

Exporting to excel from a custom class object using C#.NET

Get the Clicked Cell Value and Column Name of GridView in ASP.NET