Search code examples
asp.net-mvc-3razorportable-areas

asp.net mvc 3 razor sections and portable areas


Is it possible to have a portable area feed into a ASP.Net MVC 3 razor section? I have a section in my for placing JS files, CSS, fiels, etc. I want to be able to target the head section from portable areas for any JS, CSS files the portable area needs. Is this possible?

Thanks Tom


Solution

  • You can use master page concept just like _Layout.chtml to put portable sections. (It event works for header)

    <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>
        <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" 
                  type="text/css" />
        <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" 
              type="text/javascript">    </script>
        @{
            //access your portable section here.
        }
    </head>
    
    <body>
        @RenderBody()
    </body>
    </html>