aromore
aromore

Reputation: 1077

incorporate a html-css template as master page in asp.net- mvc 4

I am building a website, and want to do it using MVC 4. I dont want to use the custom asp.net template, and the asp.net templates available online do not meet my requirements. I have designed a html-css template and need to incorporate it into my project...(pretty much build the "contents folder" of the default templated mvc 4 project myself, if u know what i mean)...

I would really appreciate if someone points me to a tutorial or gives me a step-by-step account of how to do it.

Upvotes: 0

Views: 1001

Answers (2)

Paul Fleming
Paul Fleming

Reputation: 24526

If I'm understanding correctly, you simply want to apply your template to _Layout.cshtml. This is similar in purpose to a MasterPage in ASP.NET web forms.

Here's a ScottGu blog on layouts and sections. (Just noticed that's the same link provided by @ErikPhilips)

To provide a simple explanation. _Layout.cshtml resides at Project\Views\Shared\_Layout.cshtml. By default it looks like a normal HTML file with a couple of unusual lines. The most important being @RenderBody(). When returning a ViewResult from an action (e.g. return View("MyView, myModel)), your view gets rendered by @RenderBody inside the layout. You can do what you like with _Layout.cshtml and if you're brave, you can also nest layouts.

Upvotes: 2

Erik Philips
Erik Philips

Reputation: 54638

You're pretty much looking for how to use Layouts and Sections with Razor. You can have as many as you'd like.

Upvotes: 2

Related Questions