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!

Render CustomTag property in ViewMode


When using the following code

@Html.PropertyFor(x => x.CurrentPage.Title, new { CustomTag = "h1" })

the CustomTag property is written out while in Edit Mode, why doesn't it write out the tag in ViewMode?
Should I use a different property to write out the tag in ViewMode?


Aug 28, 2013 10:41

Hi, short answer, CustomTag is only used in edit mode for MVC.

Joel has extensively explaine the renderings:

(see the last articles EditAttributes usage, that might be the closest you are looking for maybe)

Aug 29, 2013 10:04

Hi Antti, yes i've read the excellent articles by Joel, using the EditAttributes is not sufficient because it still writes out the tag even if the property is empty. 
I'm looking for a method where the tag is not rendered if the property is empty.

Sep 02, 2013 10:37

Hi, I have used helper methods that take care of the rendering, for example if the heading is empty, then don't render the <h2>....</h2> otherwise render, but this means you need to write more code and logic compared to the built in methods.

Sep 02, 2013 10:50
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.