Sign in to follow this  
jfclavette

[.net] Master pages and custom base page class interaction problem

Recommended Posts

So here's the situation. In my website, all the pages have a master page that dictates the layout of the page. That includes a Dropdown list that acts as a menu. Each entry in that dropdown leads to a page. All the pages also derive from a custom base page class that provides common functionality like authentication and database connection management. Now, I want to populate that dropdown from the database. Since that is done in every page, and I need to make sure the user is authenticated, I obviously can't put that in the master pages (The User object is not accessible in a master page.) It wouldn't semantically belong there either since that seems to be the responsibility of the base page. The problem is, I'm not to sure how to have the base page, which is abstract, to talk to the master page. Using <%@ MasterType %> directives in the children , it is easy to do Master.MyDropDown.Add in the final pages, but is there a way to do the same from the custom base page class ?

Share this post


Link to post
Share on other sites
I'm just learning ASP.NET 2.0, but here's what I thought of: Could you make a public method in the master page's code file which does the dropdown population and takes as an argument the user credentials? Then you could call it with one line of code in each child pages', or in the child pages' base class's Page_Load function. Would that work?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this