Thursday, January 26, 2017

Various html tags in Razor



 @Html.TextBoxFor(x => Model.Subject, new { @class = "message-subject" })<br />
    @Html.ValidationMessageFor(x => Model.Subject)

Statically bind a rendering and user datasource

@Html.Sitecore().Rendering("{65717FC0-3059-4260-98D0-94736C170BD1}", new { DataSource = "{844957CE-373D-4685-8373-D4FB94E50BFC}" })



@Html.Raw() renders raw html with tags and everything. This could also be replace with regular string rendering method as long as it is an HtmlString type

new HtmlString(translatedKey)

=========== Image with Link =============

@Html.Sitecore().Field("Link", new { text = @Html.Sitecore().Field("Image") })

@model Sitecore.Mvc.Presentation.RenderingModel

@*<div>
    @Html.Sitecore().Field("Image", Model.Item, new { @class = "classname" })
    @Html.Sitecore().Field("Link", Model.Item)
</div>*@




No comments:

Post a Comment