Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Creating instance of another page class to access the control tree

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Willy Van den Driessche - 08 Jul 2007 23:53 GMT
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.
MasterGaurav (www.edujini-labs.com) - 09 Jul 2007 07:20 GMT
> 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!

Signature

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

Willy Van den Driessche - 09 Jul 2007 09:24 GMT
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.

>> 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.
[quoted text clipped - 4 lines]
>
> For the sitemap... look at the Tree Control and SitemapDataSource!
bruce barker - 09 Jul 2007 17:12 GMT
see PageParser.GetCompiledPageInstance()

-- bruce (sqlwork.com)

> Hello,
> I am writing (Yet Another) Content Management Application.  To make it
[quoted text clipped - 12 lines]
>
> Thanks in advance.
Willy Van den Driessche - 09 Jul 2007 21:52 GMT
> 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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.