I know you can access master page element from content pages in webform world by adding a reference then calling Page.Master.
How can same be done in MVC 3.0 World?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t access elements in the layout from the view – this is MVC and not Web Forms.
There are no controls like in web forms which you can reference and manipulate.
If you want to change anything in the layout from within the view:
ViewBag(as others here suggested) to pass values up to the layout (to display them, use them for conditions, pass them toRenderActioncalls or to partial views, …). The same can be done by using a commonBaseViewModeland strongly typing the layout.Rendersectionin your layout and place asectionattribute in your view – whatever you put in the section will be rendered in the layout.