I'm currently using ASP.NET MVC 2 and the spark view engine. The main master page (application.spark) contains all of the CSS link tags that need to be present for all pages (global stuff). However, I have some content pages that have page specific CSS tags and currently I'm just sticking the link tag in the body as something like:
<content name="MainContent"开发者_JAVA技巧>
<!-- page specific csss -->
<link rel="stylesheet" href="/Content/css/page_specific.css" />
My problem is that when the page renders, this tag ends up in the which is not where it needs to be. Is there a solution for this?
One idea I had was to check the controller in the Application.spark page and write out which page specific css file is required for that particular controller, however, that solution doesn't seem to scale well and I would imagine there is some way of creating the link in the child page and having it render where it's supposed to by the browser.
Did you try to define Application.spark like:
<html>
<head>
<use content="head"/>
</head>
<body>
<use content="view"/>
</body>
</html>
and then:
<content name="head">
<script type="text/javascript" src="../../Scripts/jquery-1.3.2.min.js"></script>
</content>
CONTENT OF VIEW
Here is some about master layouts: http://sparkviewengine.com/documentation/master-layouts
精彩评论