Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Optional properties and clean markup



Any recommendations on the best way to generate clean markup when you have optional properties in a block or page?

For example, I might have something like this:

@Html.PropertyFor(x => x.Intro)

If that property isn't populated, we end up with an empty


I've done something like this:

 @if (@Model.Intro != null) //or maybe check for isnunllorwhitespace?

@Html.PropertyFor(x => x.Intro)


That can get repetetive, are there any common ways to tackle this issue?


Dec 02, 2014 1:48

You could create your own DisplayTemplates that will be used instead of the default ones. See this post for more information:

Hope this helps.


Dec 02, 2014 3:14
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.