Documentation Center

New Razor view syntax (.NET)

To improve the View code usability, SDL Digital Experience Accelerator introduced the user-friendly HtmlHelper extension method.

This topic shows you examples of new API items, examples of how they are used, and comparison to the previous method. The SDL Tridion Reference Implementation 1.0 syntax is deprecated and may result in errors.

DxaRegion(region, emptyViewName, containerSize) method

Signature
DxaRegion

  regionName: string

  emptyViewName: string (optional)

  containerSize: int (optional)
Example 1
DXA 1.1
Html.DxaRegion("Logo", emptyViewName: "Core:Logo")
SDL Tridion Reference Implementation 1.0 equivalent
if (Model.Regions.ContainsKey("Logo"))
{
  ViewBag.Renderer.RenderRegion(Model.Regions["Logo"])
}
else
{
  // Construct an empty region and render it using the empty view name
}
Example 2
DXA 1.1
Html.DxaRegion("Logo")
SDL Tridion Reference Implementation 1.0 equivalent
if (Model.Regions.ContainsKey("Logo"))
{
  ViewBag.Renderer.RenderRegion(Model.Regions["Logo"])
}

DxaRegion(region, containerSize) method

Signature
DxaRegion

  region: RegionModel

  containerSize: int (optional)
 
Example
DXA 1.1
Html.DxaRegion(Model.Regions["Info"])
SDL Tridion Reference Implementation 1.0 equivalent
ViewBag.Renderer.RenderRegion(Model.Regions["Info"])

DxaRegions(exclude, containerSize) method

Signature
DxaRegions

  exclude: string (optional)

  containerSize: int (optional)
Example
DXA 1.1
Html.DxaRegions(exclude: "Logo,Info")
SDL Tridion Reference Implementation 1.0 equivalent
foreach (var region in Model.Regions.Values)
{
  ViewBag.Renderer.RenderRegion(region, new List<string> {"Logo", "Info"})
}

DxaEntity(entity, containerSize) method

Signature
DxaEntity

  entity: EntityModel

  containerSize: int (optional)
Example
DXA 1.1
Html.DxaEntity(someEntity)
SDL Tridion Reference Implementation 1.0 equivalent
ViewBag.Renderer.RenderEntity(someEntity)

DxaEntities(containerSize) method

Signature
DxaEntities

  containerSize: int (optional)
Example
DXA 1.1
Html.DxaEntities()
SDL Tridion Reference Implementation 1.0 equivalent
foreach (var entity in Model.Items)
{
  ViewBag.Renderer.RenderEntity(entity)
}

DxaRegionMarkup(region) method

Signature
DxaRegionMarkup

  region: RegionModel (optional)
Example
DXA 1.1
Html.DxaRegionMarkup()
SDL Tridion Reference Implementation 1.0 equivalent
Markup.Region(Model)

DxaEntityMarkup(entity) method

Signature
DxaEntityMarkup

  entity: EntityModel (optional)
Example
DXA 1.1
Html.DxaEntityMarkup()
SDL Tridion Reference Implementation 1.0 equivalent
Markup.Entity(Model) 

DxaPropertyMarkup(entity, propertyName, index) method

Signature
DxaPropertyMarkup

  entity: EntityModel (optional)

  propertyName: string

  index: int (optional)
Example
DXA 1.1
Html.DxaPropertyMarkup("Headline")
SDL Tridion Reference Implementation 1.0 equivalent
Markup.Property(Model, "Headline")

DxaPropertyMarkup(propertyExpression, index) method

Signature
DxaPropertyMarkup

  propertyExpression: Expression<Func<object>>

  index: int (optional)
Example
DXA 1.1
Html.DxaPropertyMarkup(() => Model.Headline)
SDL Tridion Reference Implementation 1.0 equivalent
Markup.Property(Model, "Headline")