Link to home
Start Free TrialLog in
Avatar of jimbona27
jimbona27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

access master page data

hi EE,
I have the following line of code in a master file but when trying to access it within code I get null.

When debugging through the master file it has a value but when my new code gets executed the value is null.

can someone please advise me what im doing wrong?

many thanks,



// in master file
MyMasterPageModel.ViewDataKey = "MasterPageModel";
MyMasterPageModel model = ViewData[MyMasterPageModel.ViewDataKey] as MyMasterPageModel;  // model has a value

....


// in child file

if ((MyMasterPageModel )ViewData["MasterPageModel"])  // returns null ??
{
}

Open in new window

Avatar of existenz2
existenz2
Flag of Netherlands image

Have a look at http://www.asp.net/mvc/tutorials/passing-data-to-view-master-pages-vb

It's not exactly what you are looking for, but it should give you some tips.
ASKER CERTIFIED SOLUTION
Avatar of sweetsathish
sweetsathish

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial