Get all controls of others web pages

I need to list all controls of all aspx web pages in a project.
I have the code for getting all control of current aspx page (webform1.aspx):

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            ListControlCollections()

        End If
    End Sub

    Private Sub ListControlCollections()
        Dim controlList As New ArrayList()
        AddControls(Page.Controls, controlList)

        For Each str As String In controlList

            Response.Write(str & "<br/>")


        Next
        Response.Write("Total Controls:" + controlList.Count.ToString)
    End Sub

    Private Sub AddControls(ByVal page As ControlCollection, ByVal controlList As ArrayList)
        For Each c As Control In page
            If c.ID IsNot Nothing Then
                If c.ID <> "0" Then
                    controlList.Add(c.ID)
                End If

            End If

            If c.HasControls() Then
                AddControls(c.Controls, controlList)
            End If
        Next
    End Sub

Open in new window


Problem is when I try to call the controls of other webpages (webform2.aspx, webform3.aspx, etc). Example:

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim Page As New WebForm2()
            ListControlCollections(Page)

           'Also I try this code, but get nothing:
            Dim x As New WebForm2()
            For Each ctrl As Control In x.Controls
                Response.Write(ctrl.ID & "<br/>")

            Next

        End If
    End Sub

Private Sub ListControlCollections(ByVal Page As Page)
        Dim controlList As New ArrayList()
        AddControls(Page.Controls, controlList)

        For Each str As String In controlList
            Response.Write(str & "<br/>")
        Next
        Response.Write("Total Controls:" + controlList.Count.ToString)
    End Sub

Open in new window

I get none controls of webform2.aspx

Is it possible to get all controls of other web pages?
LVL 1
miyahiraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roopesh ReddyIT AnalystCommented:
Hi,

No. You can get the current rendered Page controls only!

You can check the JavaScript solutions here - http://forums.asp.net/t/1908996.aspx?Get+all+controls+from+another+page

but i don't think it's feasible for you!

Hope it helps u...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.