Try our conversational search powered by Generative AI!

Css Class Not Applying to LinkItemCollection Render


The following code does not appear to be working correctly.  Any ideas?

@Html.PropertyFor(m => m.Layout.LegalLinks, new { CssClass = "terms", })

Renders the following

I am trying to get the class 'terms' to be applied on the


    Based on some other posts, I have also tried:

@Html.PropertyFor(m => m.Layout.LegalLinks, new { @class = "terms", })

Any ideas?  Am I missing something blatanly stupid here?

Feb 02, 2015 5:03

Hi yes you are missing the fact that the CssClass is not set on the html that is rendered by the DisplayTemplates builtin for linkitemcollection. A lot of these parameters that can be set on the html.propertyfor helper is there for editmode sadly. Have a look at these links written by Joel Abrahamsson.

CustomTag changes the type of element that wrapes the rendered property when rendered in edit mode.

CssClass does not change the CSS class for the wrapping element when rendered in edit mode. EditContainerClass does.

In view mode PropertyFor isn't much more than an alias for DisplayFor. In edit mode it adds a wrapping element to whatever is rendered by DisplayFor. The wrapping element contains attributes that the CMS uses to identify editable properties.

My recommendation is to use your own displaytemplates that you can use with propertyfor. Just create a new LinkItemCollection.cshtml in DisplayTemplates-folder. /Views/Shared/DisplayTemplates/. Then you can change the output just the way you like it.

Feb 02, 2015 9:12
* 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.