Try our conversational search powered by Generative AI!

Per Nergård
Sep 21, 2015
  1889
(1 votes)

WebControl for bootstraprows and contentareas

If there still are anyone out there using forms maybe this can be of some use.

Scenario is that you have a template with:

  • One or many rows, with different combinations of content areas and other properties.
  • All properties are rendered as columns.
  • None of the properties are required.
  • We assume that the editors either add values to all properties in a row or add no values at all.

If the editor doesn't add values to atleast one of the properties in a row we would end up with a empty bootstrap row which we don't want to.

To avoid having to write codebehind code to handle this I did a webcontrol. The webcontrol checks all inner properties (which must be of type EPiServer:Property) and if all are empty the row isn't rendered.

Example:

<Nergard:BootstrapRow CssClass="row" runat="server">
    <EPiServer:Property PropertyName="ContentArea" runat="server" CustomTagName="div" CssClass="col-md-6"/>
    <EPiServer:Property PropertyName="MainBody" runat="server" CustomTagName="div" CssClass="col-md-6"/ />
</Nergard:BootstrapRow>

You can use both the PageLink and PageLinkPropertyName attributes in the EPiServer:Property if you want to use them.

Code over at GitHub Gist:  Code.

Sep 21, 2015

Comments

Please login to comment.
Latest blogs
A day in the life of an Optimizely Developer - Enabling Opti ID within your application

Hello and welcome to another instalment of A Day In The Life Of An Optimizely developer, in this blog post I will provide details on Optimizely's...

Graham Carr | May 9, 2024

How to add a custom property in Optimizely Graph

In the Optimizely CMS content can be synchronized to the Optimizely Graph service for it then to be exposed by the GraphQL API. In some cases, you...

Ynze | May 9, 2024 | Syndicated blog

New Security Improvement released for Optimizely CMS 11

A new security improvement has been released for Optimizely CMS 11. You should update now!

Tomas Hensrud Gulla | May 7, 2024 | Syndicated blog

Azure AI Language – Key Phrase Extraction in Optimizely CMS

In this article, I demonstrate how the key phrase extraction feature, offered by the Azure AI Language service, can be used to generate a list of k...

Anil Patel | May 7, 2024 | Syndicated blog