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?
// 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 ??