reflection in web pages

  • Thread starter Thread starter Naim
  • Start date Start date
N

Naim

Hi all,

I need to iterate through web pages controls using reflection.

However when I create an instance of the web page, the controls
collection is empty.
Can anyone help ?

here's the code used:

Dim myAssembly As System.Reflection.Assembly
myAssembly = myAssembly.Load("App_Web")
Dim definedTypes As Type() = myAssembly.GetTypes
Dim myType As Type
For Each myType In definedTypes
Dim myPage As System.Web.UI.Page
Dim j As Integer
If myType.BaseType.Name = "Page" Then
myPage = myAssembly.CreateInstance(myType.FullName)
Debug.WriteLine("myPage.Controls.Count=" +
myPage.Controls.Count.ToString)
For j = 0 To myPage.Controls.Count - 1
'Do something
Next
End If
Next
 
Hello,

the controls of the page are created during the normal page lifecycle (by
calling CreateChildControls).

Why do you want to parse through your own instance of a class? Maybe there
is a better way to achieve what you want to do.

Best regards,
Henning Krause
 
hi Henning,
Thank you for your answer.
we need to generate a global resource file for all the webpages. VS2005
give us the ability to generate a local ressource file for each webpage
automatically however unfortunately this doesn't suit us very well. We
want to develop something similar but that generates one ressource file
for all web pages.
Do you know if there's a tool that can accomplish this, or do you have
an idea about how to do it.

Thank you
Naim
 
Back
Top