Everything is achievable through technology

razor syntax

Important  Umbraco CMS Razor syntax for copy paste

Master page 

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Layout = null;



in Master Layout

 <title>@RenderSection(“title”, required: false)</title>

in View

@section title{

Content Page

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Layout = “master.cshtml”;

Show Page Name


Load All content inside a Content: used to show all product in products page

@foreach (var child in Model.Content.Children)
Html.RenderPartial(child.DocumentTypeAlias, child);

Render Bundle:

In Bundle.cs

bundles.Add(new ScriptBundle(“~/bundles/bootstrap”).Include(

in view


Render Partial view;  User control 

@ Html.RenderPartial(“partialfilename”);

RenderBody; for master pages


Render Macro; external user control added by developer

@Umbraco.RenderMacro(“macroname-from-developer-section “)

Umbraco Field; Document type generic property in settings

for string type:


for image type :

if (CurrentPage.HasValue(“image”)){
var dynamicMediaItem = Umbraco.Media(CurrentPage.image);
<img src=”@dynamicMediaItem.umbracoFile” alt=”@dynamicMediaItem.Name”/>

All image in a Folder by id;1097 is test id

@using umbraco.MacroEngines
List<DynamicNode> imagelist = new DynamicNode(1097).Children.Items;
foreach(dynamic image in imagelist)
<li><img src=”@image.umbracoFile” width=”200px” height=”100px” /></li>

Navigation Partialview;

<ul class=”menu”>
<li class=”@(CurrentPage.Url == “/” ? “active” : null)”><a href=”/”>About</a></li>

@foreach (var item in CurrentPage.AncestorsOrSelf(1).First().Children.Where(“UmbracoNaviHide == false”))
<li class=”@(CurrentPage.Id == item.Id ? “active” : null)”><a href=”@item.Url.Substring(0, @item.Url.Length-1)”>@item.Name</a></li>

Droupdown with selected

var selectQ ="SELECT StatusName, StatusID FROM MyStatusTable";
List<SelectListItem> statusdropdownlistdata =newList<SelectListItem>();
bool isSelected =false;foreach(var item in db.Query(selectQ)){
    isSelected =false;if(item.StatusName=="Completed"){
        isSelected =true;}
    statusdropdownlistdata.Add(newSelectListItem{Text= item.StatusName,Value= item.StatusID.ToString(),Selected= isSelected

@Html.DropDownList("StatusTypes", statusdropdownlistdata)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s