Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewState object lost in Master Page Load

I am assigning ViewState["something"] in Page Load of content page and when I try to access the ViewState variable in Master Page Load event handler, the viewstate variable is lost.Can anyone guide me why this is happening and the solution.

like image 982
chugh97 Avatar asked Dec 18 '08 16:12

chugh97


1 Answers

Master pages and content pages do not share the same ViewState. If you are trying to pass something from the content page to the master page there are a couple of alternatives:
- use this.Context.Items that is common to the entire site during an HTTP request
- make a public property on the master page, cast this.Master from the content page to the master page class and set the property
- use Session

like image 67
Aleris Avatar answered Nov 01 '22 07:11

Aleris