Instantly share code, notes, and snippets.

Embed
What would you like to do?
@* Using with a basic TagBuilder *@
@{
var colDiv = new TagBuilder("div");
colDiv.AddCssClass("col-sm-4");
colDiv.GenerateId("featureCol");
}
<div>
@Html.Sitecore().DynamicPlaceholder("feature", colDiv, 3, 3)
</div>
@* Using with a Func<DynamicPlaceholderRenderContext, TagBuilder> *@
@functions {
TagBuilder CreateColBuilder(DynamicPlaceholderRenderContext context)
{
var builder = new TagBuilder("div");
builder.AddCssClass("col-sm-" + 12/context.PlaceholdersCount);
builder.GenerateId("featureCol" + context.Index);
return builder;
}
}
<div class="row">
@Html.Sitecore().DynamicPlaceholder("feature", CreateColBuilder, 3, 4)
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment