Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put data in a Masterpage?

How do you put a strongly typed object in ASP.NET MVC into the master page?

Do you have a ViewModelBase class that contains master page information and inherit from it for every view model, or is there a better approach?

like image 346
Alex Avatar asked Jun 02 '09 21:06

Alex


People also ask

How do I create a master page file?

To set the master page programmatically, then, we can either create an event handler for the PreInit event or override the OnPreInit method. Let's look at both approaches. From here we can set the MasterPageFile property. Update the code so that it assigns the value "~/Site.

How do you bind a content page to a master page?

The @Page directive page binds the content page to a specific master page. It defines a title for the page to be merged with the master page. User can create content by adding content controls and mapping them to the contentplaceholder controls on the master page.

What is the use of master page?

What are master pages? Master pages are used to create consistency from page to page in a document. Master pages typicially contain page headers, footers, margin and column guides, and other elements that occur on multiple pages in your document.

What is content page in master page?

A content page is an ASP.NET Web page that is associated with a master page. The master page establishes a layout and includes one or more ContentPlaceHolder controls for replaceable text and controls.


1 Answers

Alex,

I think what you are asking is, "Where is my master page controller?"

Have a look at the following link. It explains how to create an "Application Controller," an abstract class that can be inherited by your other controllers, so that you only have to write the code once that pushes your needed master page data into the view.

Passing Data to View Master Pages:
http://www.asp.net/learn/MVC/tutorial-13-cs.aspx

Also, have a look at the following link, which explains how to implement Partial Views and Subcontrollers in ASP.NET MVC:

Partial Requests in ASP.NET MVC
http://blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc/

like image 74
Robert Harvey Avatar answered Oct 15 '22 09:10

Robert Harvey