PC Review


Reply
Thread Tools Rate Thread

Global Variables / Masterpages (2.0)

 
 
Thiery Balser
Guest
Posts: n/a
 
      9th Aug 2006
Hi Everybody!


I'm stuck with the following problem:

I have a couple of pages which has all the same 'header', i.e. some common
elements. So far I realized that the best thing would be to use master
pages. This is all fine and works.

Now, there are certain variables stored in the session object which I would
like to use in the other pages. What I would like to do is to initialize the
variables, assign values to them in the Page_Load of the MasterPage and then
use in the other pages (outside the masterpage, i.e., in the pages which use
the MasterPage). Is there any smart way to do this?



Thank you very much in advance,



Thiery


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      9th Aug 2006
You just described a "smart way". - Try and see how it works.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Thiery Balser" wrote:

> Hi Everybody!
>
>
> I'm stuck with the following problem:
>
> I have a couple of pages which has all the same 'header', i.e. some common
> elements. So far I realized that the best thing would be to use master
> pages. This is all fine and works.
>
> Now, there are certain variables stored in the session object which I would
> like to use in the other pages. What I would like to do is to initialize the
> variables, assign values to them in the Page_Load of the MasterPage and then
> use in the other pages (outside the masterpage, i.e., in the pages which use
> the MasterPage). Is there any smart way to do this?
>
>
>
> Thank you very much in advance,
>
>
>
> Thiery
>
>
>

 
Reply With Quote
 
 
 
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      9th Aug 2006
Sure, creating public properties on your master page, and use the MasterType
directive.

So in your page, if you do:

<%@ masterType VirtualPath="~/template/main.master" %>

you can then access your master's properties in a strongly-typed fashion in
your page

int userId = Master.UserId;

Karl

ur master would look soemthing like:

private int _userId;
public int UserId
{
get { return _userId; }
}

Page_Load(...)
{
_userId = (int)Session["userId"];
}

--
http://www.openmymind.net/
http://www.codebetter.com/


"Thiery Balser" <(E-Mail Removed)> wrote in message
news:44d983d0$(E-Mail Removed)...
> Hi Everybody!
>
>
> I'm stuck with the following problem:
>
> I have a couple of pages which has all the same 'header', i.e. some common
> elements. So far I realized that the best thing would be to use master
> pages. This is all fine and works.
>
> Now, there are certain variables stored in the session object which I
> would like to use in the other pages. What I would like to do is to
> initialize the variables, assign values to them in the Page_Load of the
> MasterPage and then use in the other pages (outside the masterpage, i.e.,
> in the pages which use the MasterPage). Is there any smart way to do this?
>
>
>
> Thank you very much in advance,
>
>
>
> Thiery
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
masterpages with masterpages JohnE Microsoft ASP .NET 1 8th Dec 2009 01:11 AM
Global application Masterpages and Intellisense tool Microsoft ASP .NET 1 11th Jun 2006 11:06 PM
masterpages vs. CSS or Masterpages with CSS??? help me out please! Nick Wouters Microsoft ASP .NET 5 8th May 2006 11:19 AM
Re: MasterPages and Variables Kenneth Keeley Microsoft ASP .NET 2 7th Sep 2005 05:45 AM
Global variables on par with ASP's global.asa Wayne Microsoft ASP .NET 2 11th Nov 2003 11:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:43 PM.