Extracting runat server objects from aspx

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

Hi All,

I'm trying to programmatically extract all of the objects in a .aspx
page that can be seen from code. This is basically anything that has an
id and runat=server element. So far I've managed to load the assembly
into my code and list all of the page classes, the problem is that I
cannot get lower down than the page object.

This is from another application instance, so I cannot cycle through
the page.controls recursively as it does not exist in the code that I
am running from.

Any code samples/hints would be greatly appreciated. FYI this is for an
app that loads a .net dll dynamically and then creates a resource file
containing all of the user displayable elements (HTML selects, buttons,
images etc) on every asp.net page. This resource file can then be
localised to German, French etc by someone else (not me).
Thanks in advance for any hints

Ryan
 
Ryan said:
Hi All,

I'm trying to programmatically extract all of the objects in a .aspx
page that can be seen from code. This is basically anything that has an
id and runat=server element. So far I've managed to load the assembly
into my code and list all of the page classes, the problem is that I
cannot get lower down than the page object.

This is from another application instance, so I cannot cycle through
the page.controls recursively as it does not exist in the code that I
am running from.

Any code samples/hints would be greatly appreciated. FYI this is for an
app that loads a .net dll dynamically and then creates a resource file
containing all of the user displayable elements (HTML selects, buttons,
images etc) on every asp.net page. This resource file can then be
localised to German, French etc by someone else (not me).

You're not going to be able to do this by Reflection. You're actually going
to have to execute the page in order to get the controls created. What
about pages which don't use codebehind, for instance? Those controls never
get instantiated until the page is parsed and executed.

Microsoft experimented with a technology called the Enterprise Localization
Toolkit. You might look that up for some ideas. However, it didn't
automatically find all controls. I don't think that what you want to do is
possible.

John Saunders

P.S. You might do better in the microsoft.public.dotnet.framework.aspnet
newsgroup
 
Thanks,

Tried the MS stuff, it nearly does it to the point of being very
frustrating. Lots of code missing and the docs are a bit poor. I bet it
is another 2.0 thing that we'll have to wait for.
 
Ryan,
You could use regex and parse the actual aspx files. Would this
approach work for you?

Cecil Howell MCSD, MCAD.Net, MCT
 
Back
Top