How I can clear the textboxes in the webbform.

Recommended Answers

All 3 Replies

I found the solution like this,

EmptyTextBoxValues(this);
private void EmptyTextBoxValues(Control parent)
    {
        foreach (Control c in parent.Controls)
        {
            if ((c.Controls.Count > 0))
            {
                EmptyTextBoxValues(c);
            }
            else if ((c.GetType() == typeof(TextBox)))
            {
                ((TextBox)(c)).Text = "";
            }
            
        }
    }

the best and easiest way is to write a single event handler for all textboxes on the form

MAke a linkbutton with name 'clear'
on its button event handler just blank all text boxes resides on the page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.