List of Pages

J

John Saunders

JezB said:
Can I programatically get a list of Pages that are part of an ASP.NET
assembly ?

You could use Reflection to iterate through all the classes in the assembly
and then look at those which derive from System.Web.UI.Page.
 
J

JezB

I could indeed, good idea. I'll give it a try.

John Saunders said:
You could use Reflection to iterate through all the classes in the assembly
and then look at those which derive from System.Web.UI.Page.
 
J

JezB

For the record:

private ArrayList GetPages(Assembly a)
{
ArrayList pages = new ArrayList();
foreach (Type tt in a.GetTypes())
{
if (tt.BaseType.Name == "Page")
pages.Add(tt.Name);
}
return pages;
}
 
J

John Saunders

JezB said:
For the record:

private ArrayList GetPages(Assembly a)
{
ArrayList pages = new ArrayList();
foreach (Type tt in a.GetTypes())
{
if (tt.BaseType.Name == "Page")
pages.Add(tt.Name);
}
return pages;
}

I think that tt.IsSubClassOf(typeof(System.Web.UI.Page)) would work better.
Yours will pick up my own type called "Page".
 
J

JezB

Yes, that's cleaner - thank you.
(IsSubclassOf)

John Saunders said:
I think that tt.IsSubClassOf(typeof(System.Web.UI.Page)) would work better.
Yours will pick up my own type called "Page".
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top