Dear all,
This code below is used to clear TextBox and dropdownlist control value

Public Sub ClearPage(ByVal Pg As Page, ByVal Form As String, Optional ByRef ClearCombo As Boolean = False)
        Dim Obj As Object
        For Each Obj In Pg.FindControl(Form).Controls
            If Obj.GetType().Name = "TextBox" Then
                Obj.Text = ""
            End If
            If LCase(Obj.GetType().Name) = "htmlinputtext" Then
                Obj.value = ""
            End If
            If LCase(Left(Obj.id, 2)) = "lb" Or LCase(Left(Obj.id, 3)) = "lbl" Then
                If LCase(Obj.GetType().Name) = "htmlinputtext" Then
                    Obj.value = ""
                ElseIf LCase(Obj.GetType().Name) = "htmlgenericcontrol" Then
                    Obj.InnerText = ""
                Else
                    Obj.Text = ""
                End If
            End If
            If Obj.GetType().Name = "HiddenField" Then
                Obj.Value = ""
            End If
            If Obj.GetType().Name = "DropDownList" Then
                If ClearCombo = True Then
                    Obj.items.clear()
                Else
                    If Obj.Items.Count > 0 Then
                        Obj.SelectedIndex = 0
                    End If
                End If
            End If
        Next
    End Sub

and

in my aspx forms, I write this code :

ClearPage(Me, "form1")

My question is, How do I find all controls in aspx forms that link to MasterPage ?
I have changed the code like this :

Public Sub ClearPage(ByVal Pg As MasterPage, ByVal Form As String, Optional ByRef ClearCombo As Boolean = False)
        Dim Obj As Object
        For Each Obj In Pg.FindControl(Form).Controls

        Next Obj

End Sub

and

ClearPage(Master, "aspnetForm")

but not working !!!

Thanks,

Kusno.

u can use master.findcontrol("controlid")

It means, I must know all controls ID. In my case, I want to automatically find the controls ID.

This article has been dead for over six months. Start a new discussion instead.