1

I encounter in some web app that some partial view that is used has head element (it loads some Jquery things).

The thing is that with that and the _layout.xml I get this wierd HTML page structure

    <head>
...
    </head>
    <body>
...
    </body>
    <head>
...
    </head>
    <body>
....
    </body>

doesn't feel right..

  1. What's the best practice to load some .css.js to particular page? is it all done by _layout.xml and bundles?

  2. and in general - only _layout.xml should contain head element? no other view in my solution?

user1025852
  • 2,684
  • 11
  • 36
  • 58

1 Answers1

0

You want only one head. Use layout with sections and add MVC sections in normal pages to add CSS or JScript. See here on basic section usage http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx. If you want to use partial create a helper to render section from partial see this answer Using sections in Editor/Display templates

Community
  • 1
  • 1
GraemeMiller
  • 11,973
  • 8
  • 57
  • 111