468,101 Members | 1,346 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,101 developers. It's quick & easy.

MasterPages and Variables

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
Nov 19 '05 #1
6 1532
You should add the <%@ MasterType VirtualPath="YourMaster.master" %> to your
ASPX pages.

http://beta.asp.net/QUICKSTART/aspne...ault.aspx#code

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #2
Thanks for the help.
That was what I was looking for.

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
You should add the <%@ MasterType VirtualPath="YourMaster.master" %> to your ASPX pages.

http://beta.asp.net/QUICKSTART/aspne...ault.aspx#code

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #3
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

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
You should add the <%@ MasterType VirtualPath="YourMaster.master" %> to your ASPX pages.

http://beta.asp.net/QUICKSTART/aspne...ault.aspx#code

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #4
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
You should add the <%@ MasterType VirtualPath="YourMaster.master" %>
to

your
ASPX pages.

http://beta.asp.net/QUICKSTART/aspne...efault.aspx#co
de

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #5
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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
You should add the <%@ MasterType VirtualPath="YourMaster.master" %>
to

your
ASPX pages.

http://beta.asp.net/QUICKSTART/aspne...efault.aspx#co
de

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #6
I'd suggest looking at the quickstarts to get you going:

http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

-Brock
DevelopMentor
http://staff.develop.com/ballen
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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:11***********************@msnews.microsoft.co m...
You should add the <%@ MasterType VirtualPath="YourMaster.master"
%> to

your

ASPX pages.

http://beta.asp.net/QUICKSTART/aspne.../default.aspx#
co de

-Brock
DevelopMentor
http://staff.develop.com/ballen
> 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


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Roger Walter | last post: by
3 posts views Thread by Lars W. Andersen | last post: by
2 posts views Thread by iturner100 | last post: by
2 posts views Thread by Thiery Balser | last post: by
6 posts views Thread by =?Utf-8?B?U3RlcGhlbiBIYXRmaWVsZA==?= | last post: by
8 posts views Thread by Mort Strom | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.