Welcome to WebmasterWorld Guest from 18.210.27.34

Forum Moderators: ocean10000

Message Too Old, No Replies

Accessing changed global var. value from content to master pages

Accessing changed global var. value from content to master pages

     
11:05 pm on Sep 23, 2009 (gmt 0)

New User

10+ Year Member

joined:Oct 25, 2004
posts: 21
votes: 0


I have a master page and content page, each with their own codeBehind.

I am trying to reference a global variable of the master from the content, no problem, I can access is ok.

However, this global variable is changed in the master page's Page_Load phase, but the new value is not picked up in the content page. The value is read in the content pages' codeBehind Page_Load method.

What am I doing wrong?

Thanks,
Paul.

12:24 am on Sept 24, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


Content Page Page_Load is triggered before the Master Page Load Event.

Events in ASP.NET Master and Content Pages [msdn.microsoft.com]

So you are not doing anything wrong per say. Just the load order isn't what one would expect is all.

4:32 am on Sept 24, 2009 (gmt 0)

New User

10+ Year Member

joined:Oct 25, 2004
posts:21
votes: 0


Ha ha! I knew that, but forget!

I moved the variable change to the master page's Page_Init and it works fine.

Thanks a lot,
Paul.