How to Get a collection of page-names from your current project

G

Guest

I have a testproject with a number of pages. Here I want to build a Array
with all page-names(physical name & ID's). This array will be used to fill a
listbox/table/ something else.

QUESTION : How to get all pages within your project??
 
W

William F. Robertson, Jr.

You will need to use reflection for that. Here is a snippet of some code I
have written serving a different purpose.

bill

System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFile(
@"C:\inetpub\wwwroot\test\bin\test.dll" );
Type baseType = null;
bool IsPage = false;
string pagename = null;
int badCount = 0;
foreach( Module mod in ass.GetModules() )
{
foreach( Type type in mod.GetTypes() )
{
IsPage = false;
baseType = type;
while ( baseType != typeof( object ) )
{
if ( baseType == typeof( dascweb.Pages.Page ) )
{
IsPage = true;
break;
}
baseType = baseType.BaseType;
}

if ( IsPage )
{
//add the baseType + ".aspx" to get the name of the page. This
is assuming that all your class names mirrors the name of the 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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top