By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Best Use of Master Pages - dynamic content and event handling

P: n/a
I'm creating an application that has a standard layout for all pages.
The information that is displayed in the layout will be dynamic based
on the user that is logged in. Thus when a page is browsed to, I need
to check to see if the user has logged in or not. Then if they have
logged in, I need to pull their information from the database to
display in the header.

In previous applications, I made use of a base web page that all the
content pages inherited from to check whether they were logged in and
to create a database connection. With VS 2005, I thought I'd try to
make use of the Master Page to incorporate the standard layout. But I'm
not sure of the best way to do this with the base web page
functionality and the master page combined. Do I query the database for
the user information from the Master page or the base web page class?
Also as I click on different buttons in the layout, different
information is displayed - should the Master page handle that click
event - if so, how do I get the content page to refresh according to
what they have clicked?

Also would the best route for the user information to be to collect it
the first time a user logs in and then store it in session variables so
I don't have to query the database for the user information every time?
The impression has always been that session variables are bad so I've
avoided them but are they safe with 2005 now (across multiple servers
as well).

Sorry for all the questions but I just want to make sure I'm using the
Master Page functionality in the recommended way. I've read a number of
articles from MSDN and other sites but haven't found any solid ideas
surrounding my particular implementation.

I appreciate all suggestions!

Apr 30 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 29 Apr 2006 17:12:56 -0700, "LilC" <ca*********@hotmail.com> wrote:
I'm creating an application that has a standard layout for all pages.
The information that is displayed in the layout will be dynamic based
on the user that is logged in. Thus when a page is browsed to, I need
to check to see if the user has logged in or not. Then if they have
logged in, I need to pull their information from the database to
display in the header.

In previous applications, I made use of a base web page that all the
content pages inherited from to check whether they were logged in and
to create a database connection. With VS 2005, I thought I'd try to
make use of the Master Page to incorporate the standard layout. But I'm
not sure of the best way to do this with the base web page
functionality and the master page combined. Do I query the database for
the user information from the Master page or the base web page class?
Also as I click on different buttons in the layout, different
information is displayed - should the Master page handle that click
event - if so, how do I get the content page to refresh according to
what they have clicked?

Also would the best route for the user information to be to collect it
the first time a user logs in and then store it in session variables so
I don't have to query the database for the user information every time?
The impression has always been that session variables are bad so I've
avoided them but are they safe with 2005 now (across multiple servers
as well).

Sorry for all the questions but I just want to make sure I'm using the
Master Page functionality in the recommended way. I've read a number of
articles from MSDN and other sites but haven't found any solid ideas
surrounding my particular implementation.

I appreciate all suggestions!


Think of it this way...

The reason for using the masterpage is to do all the things you repeat on all of
the pages on the masterpage, so anything you are doing to all of the pages can
go on the masterpage. Yes, you can pull the data for the master page from the
database. You may even find that you don't have to do it but one time per
session. Think of the master page as a frame, but understand that it is not ;o)

Session variables have always been OK, but you must be aware that if your web
site is hosted in a web farm there will be problems, unless the web farm is
setup with a state server. This is not a problem, but you will need to reset
some switches in your web.config file if the site is on a farm. Your site admin
can help you with that.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Apr 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.