0

knows anyone an article I can implement a template-system in my ASP.NET MVC 4 application?

Like many other websites, my own has many different categories and for each should use there own template.

The color circle is the template (like musictemplate_layout.cshtml) and ContentPlaceHolder123 has always the same content.

enter image description here

Best regards, Patrik

Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
Patrik
  • 1,119
  • 5
  • 18
  • 37

1 Answers1

1

Create different Views as your specific templates like bellow: enter image description here

Use different layouts by defining at the top of each page like bellow:

@{
    Layout = "~/Views/Shared/Layout1.cshtml";
}

Also, you can have more levels of Layouts, according to your interface plans. You can use layouts dynamically by different factors, like UserAgent or ... by Placing string variable in front of 'Layout' for more adoptable or intelligent results.

Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
  • Hey, thank you for comment. What exactly is _Common? I just found _ViewStart in my project folder with the definition of Layout. I'm thinking that your way is the correct, but how can I manipulate the layout variable? Somehow, it must indeed be possible to read the category out of the url /Category1/Book123 or read it out of the database.. – Patrik Jan 04 '13 at 12:28