While you could have full control over the HTML, the solution was what was needed, so here is one :-)
On the _layout.cshtml page
<body class="@RenderSection("BodyClass", false)">
This will look for a section on all child pages, but says don’t worry if it cannot find one
Then in your child’s views just do it
@section BodyClass {productList}
Keep it on one line and then the HTML output will look great, also you can also create class names.
@section BodyClass {productList generic}
This idea fits perfectly with the specific DOM-Ready page code, why not check out http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/
Or my extended version is here https://github.com/AaronLayton/H5BP-Core
My method allows you to do page code, but allows you to store all Javascript on separate pages so that each page becomes easily manageable. The final step would be to merge and minimize all JS into 1 file; -)
Aaron
source share