Live Chat Icon For mobile
Live Chat Icon

How to clear all the textboxes in my form

Platform: ASP.NET| Category: TextBox

VB.NET


Dim ctl As Control
For Each ctl In Page.Controls(1).Controls
            If TypeOf ctl Is TextBox Then
                CType(ctl, TextBox).Text = ''
            End If
Next

C#


foreach (Control ctl in Page.Controls[1].Controls )
{
	TextBox tb = ctl as TextBox;
	if (tb!=null)
	{
	tb.Text = '' ;
	}
}

Note: Page.Controls[1]=> control is within the

tag

Share with

Share on twitter
Share on facebook
Share on linkedin