Sitefinity add class to control template list item

Posted by Community Admin on 05-Aug-2018 16:25

Sitefinity add class to control template list item

All Replies

Posted by Community Admin on 24-Jul-2012 00:00

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"];
                    hyperLink.Attributes.Remove("class");


                    
                    if (!string.IsNullOrEmpty(classValue))
                   
                        if (classValue.IndexOf("activeVerticalNav") == -1)
                       
                            classValue += " activeVerticalNav";
                       
                   
                    else
                   
                        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.

This thread is closed