Render CustomTag property in ViewMode

Vote:
 

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?

 

#74457
Aug 28, 2013 10:41
Vote:
 

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

Joel has extensively explaine the renderings:

http://joelabrahamsson.com/episerver-7-and-mvc-custom-tags-and-css-classes-when-rendering-properties/

http://joelabrahamsson.com/episerver-7-and-mvc-how-to-customize-rendering-of-properties/

http://joelabrahamsson.com/how-episervers-html-helper-propertyfor-works/

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

#74484
Aug 29, 2013 10:04
Vote:
 

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.

#74572
Sep 02, 2013 10:37
Vote:
 

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.

#74574
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.