Breadcrumbs and CSS
-
- Commander (CMDR)
- Posts: 118
- Joined: Sat Dec 20, 2008 11:27 pm
Breadcrumbs and CSS
I'm trying to figure out how to modify the code of CategoryBreadCrumbs.ascx.cs so that the last (lowest category level) would be displayed with CSSClass="lowestLevel" so that I can format just that last level in CSS. I can format all the breadcrumbs or just all the subcategories, but I want to format the last subcategory differently, sort of a "you are here" kind of thing. How can I modify the code to add a class to that last level to be able to hook it with CSS?
Re: Breadcrumbs and CSS
Edit your ConLib/CategoryBreadCrumbs.asx file and locate following code in it
Now update it as below
Finally edit the ConLib/CategoryBreadCrumbs.asx.cs file and add following method to it
save it. Now try some styles against css class called lastCategory.
Code: Select all
<asp:HyperLink ID="BreadCrumbsLink" runat="server" NavigateUrl='<%#UrlGenerator.GetBrowseUrl((int)Eval("catalogNodeId"), (string)Eval("name"))%>' Text='<%#Eval("Name")%>'></asp:HyperLink>
Code: Select all
<asp:HyperLink ID="BreadCrumbsLink" runat="server" NavigateUrl='<%#UrlGenerator.GetBrowseUrl((int)Eval("catalogNodeId"), (string)Eval("name"))%>' Text='<%#Eval("Name")%>' CssClass='<%#GetCssClass(Eval("CategoryId")) %>'></asp:HyperLink>
Code: Select all
protected string GetCssClass(object value)
{
Category category = CategoryDataSource.Load(_CategoryId);
int previousCategoryId = AlwaysConvert.ToInt(value);
string cssClass = string.Empty;
if (category.ParentId == previousCategoryId)
cssClass = "lastCategory";
return cssClass;
}