Best Use of Master Pages - dynamic content and event handling

L

LilC

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!
 
O

Otis Mukinfus

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
 

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,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top