MasterPages and Variables

K

Kenneth Keeley

Hi,
I have a Masterpage that controls the basic layout of the pages displayed
on a web site. The masterpage also uses some variables. I would like to be
able to access some of these variables from the content pages. Can this be
done and if so how. I have made the Varibles that I wish to access Public
Members.

Thanks for any help.
Kenneth
 
K

Kenneth Keeley

Hi,
I have given this a go but I am still having problems with my code
generated variables. I have a master page that checks the authenication
ticket to see who is logged in. I then want to store the information about
the logged in user in variables. the content pages then need to be able to
access the variables to enable the content pages to change based ono the
logged in user details.
Can I make this happen and if so How do I do it.
Thanks
Kenneth
 
B

Brock Allen

You need to make the members public on the Master page. So in the Master
code (either inline in .master in <script runat=server> or in codebehind:

string _address;

public string UserAddress
{
get { return _address; }
}

But given whet you described, I'd suggst doing it differently. Instead consider
just having a seperate class (perhaps in App_Code) with all static methods/properties
like "CurrentUserAddress" that does the lookup dynamically (based upon HttpContext.Current.User.Identity.Name)
and caches the results in the ASP.NET data Cache. This was any page, control
or master can call into the API and you're ont dependant upon using a particular
master page to do this work.
 
K

Kenneth Keeley

Thanks for the idea, could you supply a small sample of the code to show how
this is done. I am still fairly new to C# and ASP.Net.
Thanks again
Kenneth
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top