Creating instance of another page class to access the control tree

  • Thread starter Willy Van den Driessche
  • Start date
W

Willy Van den Driessche

Hello,
I am writing (Yet Another) Content Management Application. To make it
easier for the end-users, I would like to retrieve the structure of the
website. To do this, I would like to "walk the tree structure" of the
website. The structure of the site is inside custom ASP controls in the
pages of the site. What I need is a way to instantiate the class behind a
page, so that I can discover it's structure using the controls tree (and
then navigating to other pages etc until I have the entire structure of the
site). I need the "instantiated class", not it's HTML output. Essentially
I want a line of code that would do

dim pageToDiscover as new Index.aspx

Any suggestions ?

Thanks in advance.
 
M

MasterGaurav \(www.edujini-labs.com\)

then navigating to other pages etc until I have the entire structure of
the site). I need the "instantiated class", not it's HTML output.
Essentially I want a line of code that would do

You do not, and should not instantiate the ASPX-Classes.
Why do you need it anyway?

For the sitemap... look at the Tree Control and SitemapDataSource!


--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
 
W

Willy Van den Driessche

That's rather unuseful as an answer.

I don't only want the structure of the site (I have written my own
Sitemapprovider to deal with that). I want the structure of the pages.
I can manually specify that structure somewhere but that would just be
repeating the structure that is already in the pages. In order to be always
up to date I want the pages themselves to be the only source for this
structure information. This means a webservice should be able to
instantiate them and walk the trees (not only the site tree, also the
controls trees inside each page). I could parse the pages myself but
ASP.NET already has all the functionality I need (and better then I would
write it). So I just want to access that process in a simple way.

Willy.
 
W

Willy Van den Driessche

bruce barker said:
see PageParser.GetCompiledPageInstance()
Thanks, that put me on the right track. I was able to use your solution to
get to the class of the page (I also tried reflection on
System.Web.Compilation.BuildManager.GetCompiledAssembly as well as
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath) which all
gave the same results. Unfortunately, the controls collection of these page
instances were empty (Probably because these instances need to go through a
normal page lifecycle in order to be "filled".)

I finally managed to do what I wanted through the ParseControl method of the
page class (I read the entire ASPX file in memory and pass it to this method
to receive a hierarchical control tree)

I have some work left but mymain problem is probably solved.
So thanks everybody for helping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top