views:

263

answers:

1

Hi

Asp.net: Can we use MasterPage's viewstate in ContentPage ?

+1  A: 

Master pages and content pages do not share the same ViewState. If you are trying to pass something from the master page to the content 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 in the master page, use @MasterType in ContentPage. Set the value of the property as value in ViewState in Master Page's events and access them in the Content Page.
  • use Session

For setting the values and retrieving them you would need to play with the Master-Content page events carefully... :-)

Manish
@Manish: Could you please send me here an example ?
odiseh