views:

39

answers:

1

How do I obtain a list of all of the pages within an asp.net mvc project for use in a dropdown list.

I'd also like to obtain a list of all of the controls within that page.

The problem is that I'd be calling this from a different project in the same solution.

Can i use reflection for this????

+1  A: 

You can use reflection to look at the classes in an assembly and see if they inherit from System.Web.UI.Page which would indicate if its a page. I'd look at the directory of the project(s) using a DirectoryInfo object and just filter the selection by the extension ".aspx"

Achilles
What about the controls within that page??
hminaya
I'm confused about the controls...MVC doesn't have web controls like web forms. If you are using web forms you can parse the designer.vb file for each page.
Achilles
Nop., I'm using MVC, I meant regular controls, like HTML textbox and HTML Dropdowns, etc... Basically MVC uses helper methods to generate the markup, I guess I could parse those helper methods
hminaya
That seems to be a valid approach because I'm assuming there is a one to one relationship between the helper methods and the controls they generate...?
Achilles
yes, there is if you count the parameters.....
hminaya