Reputation: 3281
I am using razor view engine outside of mvc framework. Before you wonder, there are some project specific reasons.
So While adding pages, I add .cshtml layout and content page. The question is without mvc framework(which takes out possibility of viewback,tempdata) , How can I access variable/data on layout page in content cshtml page? For example: If I have in layout
@data=DB.GetData()
Then Can I have @data accessible in content .cshtml page?
Upvotes: 0
Views: 732
Reputation: 1038730
You can use the PageData
dictionary:
@{PageData["data"] = DB.GetData();}
or if you are a fan of dynamic stuff:
@{Page.data = DB.GetData();}
Upvotes: 1