List of Pages

  • Thread starter Thread starter JezB
  • Start date Start date
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.
 
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.
 
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;
}
 
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".
 
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".
 
Back
Top