473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

reflection in web pages



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
*** Sent via Developersdex http://www.developersdex.com ***
May 16 '07 #1
2 1231
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

"Naim" <an*******@devdex.comwrote in message
news:eF****************@TK2MSFTNGP04.phx.gbl...
>

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
*** Sent via Developersdex http://www.developersdex.com ***
May 16 '07 #2


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

*** Sent via Developersdex http://www.developersdex.com ***
May 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
3
by: Eric Sabine | last post by:
This is for a web app but I figured it's more of a lanugage Q: I have a user control which is going to be used by multiple web pages. In the web control I need to get the bool value of a public...
0
by: Shawn Hogan | last post by:
Hi everyone, I've been trying to execute a control's private event code via reflection from another class with the goal of potentially doing some unit testing. The examples below are trying to...
5
by: glayos | last post by:
Hi all, i have a question about the framework reflection. I have a project with some pages and a component class file. Inside this file I've placed some custom objects. Using the reflection and...
4
by: Per Bolmstedt | last post by:
(This question has been asked previously in this group, but I don't think it was ever really properly answered.) I want to use reflection - preferably - to find all Web Forms in my web site that...
2
by: Chris | last post by:
Is there any way I can "load" an aspx file and examine, which controls are on the page. A little bit like reflection? Regards, Chris.
2
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have an asp.net web page (say page.aspx) which derives from a custom base page object (CustomPage : BasePage : System.Web.UI.Page) Which has a method called DoSomething(params). My web...
3
by: Tod Birdsall | last post by:
Hi, My boss has asked me to create a tool that can give us a list of stored procedure names that are being called from each of our app's web pages. This is an ASP.NET application that is rather...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.