More in this section
Forums / Designing & Styling / Sitefinity add class to control template list item

Sitefinity add class to control template list item

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Bill
    Bill avatar
    2 posts
    15 Feb 2012
    24 Jul 2012
    Link to this post
    I am trying to add a class to a Sitefinity control tmeplate list item.

                 if (hyperLink.NavigateUrl == currentNode.Url)
                        m_log.Debug("    Item is current");
                        classValue = hyperLink.Attributes["class"];

                        if (!string.IsNullOrEmpty(classValue))
                            if (classValue.IndexOf("activeVerticalNav") == -1)
                                classValue += " activeVerticalNav";
                            classValue = "activeVerticalNav";
                        hyperLink.Attributes.Add("class", classValue);

    I can style the hyperlink in the control template, but the the hyperlink's parent.

    I tried to cast the RadListViewDataItem to HtmlGenericControl to add a class, but this does not work.

    HtmlGenericControl hyperLinkLi = (HtmlGenericControl) hyperLink.Parent;

    How can I add a class to the list item?

    Thanks in advance.
1 posts, 0 answered