Thursday 3 November 2011

How to Clear All text Boxes and DropDownList in Asp.net(Web Applications)

Public Sub clearAlltextbox(ByVal fr As ControlCollection)
        For Each c As Control In fr
           If c.ToString.Equals("System.Web.UI.WebControls.TextBox"Then
                CType(c, TextBox).Text = ""
            End If

            If c.ToString.Equals("System.Web.UI.WebControls.DropDownList") Then
                CType(c, DropDownList).ClearSelection()
            End If

        Next

    End Sub


How to Call:

if Form Controls:

clearAlltextbox(Me.Form.Controls)

if Panel Conrtols:

clearAlltextbox(Me.Panel2.Controls)


No comments:

Post a Comment