Developer forum

Forum » Templates » Render sections razor

Render sections razor

Martin Grønbekk Moen
Reply

Is it possible to use RenderSections like here.
http://stackoverflow.com/questions/16611413/how-to-render-script-in-head-section-asp-net-mvc-razor

I tried, it did not throw any warnings but the content was not applied.

 


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Martin

RenderSections is a ASP.NET MVC feature and not a Razor feature as such. Dynamicweb is not ASP.NET MVC, so it will not work like that.

If you take a look in the Razor docs this is covered - you can use snippets or helpes instead. See this: http://developer.dynamicweb.com/documentation/for-designers.aspx

You can use masters and layouts and call functions between them. See below and example attached.

Master

@using System
@using System.Web
 
<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>@GetGlobalValue("Global:Page.Top.Name")</title>
 <meta name="description" content="DynamicWeb - Bootstrap 3 Template">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
 <meta name="robots" content="index, follow">
 @RenderScripts()
</head>
<body>
@ContentPlaceholder()
</body>
</html>

​Layout using a master

@MasterPageFile("SampleMaster.cshtml")
 
<section>
 <div class="container">
  <div class="row dwcontent" id="maincontent" title="Content area">
 
  </div>
 </div>
</section>
 
@helper RenderScripts()
{
 <script type="text/javascript" src="@Url.Content("/Scripts/SomeScript.js")"></script>
}
Votes for this answer: 1

 

You must be logged in to post in the forum