SaaS CMS has officially launched! Learn more now.

PageTree: Applying a class to the first item at the top level



I am using a PageTree to display a submenu. I want to apply a class to the first item at the top level (i.e. the first item in the TopTemplate).

Can anyone advise me on how to achieve this?




Sep 07, 2010 9:30

If you can't find a way of doing it with the templates you can always do it by adding a databinding to a property which returns different data depending on whether it's called for the first time or not. Something like:


.... <div class='normalclass <%#MyFlag ? String.Empty : "my_extra_class" %>'>...


protected bool MyFlag
bool oldFlag = _myFlag; // private field
_myFlag = true; // Flag that it's been hit
return oldFlag; // Returns false first time, then true for all additional times

It's probably a good thing to reset the flag in the OnDataBinding event or similar so you know it's state when databinding starts.

Sep 07, 2010 10:02

You could also check the Container.ItemIndex.

Sep 07, 2010 13:55
* 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.