Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.

 

Per Nergård
Sep 21, 2015
  1966
(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
Level Up with Optimizely's Newly Relaunched Certifications!

We're thrilled to announce the relaunch of our Optimizely Certifications—designed to help partners, customers, and developers redefine what it mean...

Satata Satez | Jan 14, 2025

Introducing AI Assistance for DBLocalizationProvider

The LocalizationProvider for Optimizely has long been a powerful tool for enhancing the localization capabilities of Optimizely CMS. Designed to ma...

Luc Gosso (MVP) | Jan 14, 2025 | Syndicated blog

Order tabs with drag and drop - Blazor

I have started to play around a little with Blazor and the best way to learn is to reimplement some old stuff for CMS12. So I took a look at my old...

Per Nergård | Jan 14, 2025

Product Recommendations - Common Pitfalls

With the added freedom and flexibility that the release of the self-service widgets feature for Product Recommendations provides you as...

Dylan Walker | Jan 14, 2025