<asp:SiteMapPath ID="SiteMapPath1" runat="server" PathSeparator=" " ParentLevelsDisplayed="1"> <CurrentNodeStyle CssClass="LinkSJ" /> <NodeStyle CssClass="LinkSJ" /> <RootNodeStyle CssClass="LinkSJ" /> </asp:SiteMapPath>
a.LinkSJ{ background:url(../Images/Cn/ClientSJ.gif) no-repeat 0px 2px; color:#FFFFFF; padding-left:20px; padding-right:20px;}span.LinkSJ{ background:url(../Images/Cn/ClientSJ.gif) no-repeat 0px 2px ;color:#FFFFFF; padding-left:20px; padding-right:20px;}
Of course, you can also refer to the following code to do this. I personally think it is quite troublesome.
By setting control parameters or configuring the template that acts on the control, you can customize the visual appearance of the website navigation control. The template and style applied to the link follow the two priority rules inSiteMapPath
OfRemarks
This section is described.
In addition, you can apply themes or control skins to controls, or develop custom website navigation controls that meet special rendering requirements.
SiteMapPath
Controls display a navigation path (separated by special characters), and displays the path of the current page returned to the home page by link. On the ASP. NET page,SiteMapPath
The display of the control may be as follows:
Home> services> Training
TreeView
AndMenu
The widget can also display website map dataSiteMapPath
Controls are similar. They can be customized like most other Web controls. This article describes how to useSiteMapPath
The following custom features of a widget:
Specifies the delimiter or image displayed between links.
Returns the direction of the navigation path.
Specify the number of parent links displayed.
All the steps in this document assume that you have created a website map file and containSiteMapPath
Control page.
Custom link style attributes
In the includeSiteMapPath
Add the following attributes to the control on the ASP. NET web page of the control:
Rootnodestyle-font-names = "verdana" rootnodestyle-forecolor = "orange" rootnodestyle-borderwidth = 2
For exampleSiteMapPath
The control code may be as follows:
<Asp: sitemappath id = "sitemappath1" runat = "server" skiplinktext = "Skip menu" rootnodestyle-font-names = "verdana" rootnodestyle-forecolor = "orange" rootnodestyle-borderwidth = 2> </ASP: sitemappath>
TheStyle
AndFontInfo
Most attributes of an object are valid, includingCssClass
Attribute.
If you need to specify different style content for each link, repeat the previous steps and setSiteMapPath
ControlParentNodeStyle
,CurrentNodeStyle
, AndPathSeperatorStyle
Attribute.
Tip: to improve performance, you can useNodeTemplate
The object can be customized for all styles at a time.
Custom delimiter characters displayed between links
In the includeSiteMapPath
AddPathSeparator
Attribute.
For exampleSiteMapPath
The control code may be as follows:
<Asp: sitemappath id = "sitemappath1" runat = "server" pathseparator = ":"> </ASP: sitemappath>
The currentSiteMapPath
The display of the control may be as follows:
Home: Services: Training
You can use any string to separate links or even use images. Follow these steps.
Specify the image displayed between links
In the includeSiteMapPath
Add the following code to the control on the ASP. NET web page of the control:
<Pathseparatortemplate> <asp: Image id = "image1" runat = "server" width = "20" imageurl = "images/pathseparatorimage.jpg"/> </pathseparatortemplate>
For exampleSiteMapPath
The control code may be as follows:
<Asp: sitemappath id = "sitemappath1" runat = "server"> <pathseparatortemplate> <asp: image id = "image1" runat = "server" width = "20" imageurl = "images/pathseparatorimage.jpg"/> </pathseparatortemplate> </ASP: sitemappath>
Reverse display onSiteMapPath
Control path direction
In the includeSiteMapPath
AddPathDirection
AndPathSeparator
Attribute.
For exampleSiteMapPath
The control code may be as follows:
<Asp: sitemappath id = "sitemappath1" runat = "server" pathdirection = "currenttoroot" pathseparator = "<--"> </ASP: sitemappath>
Limit the number of parent links displayed
In the includeSiteMapPath
AddParentLevelsDisplayed
Attribute.
For exampleSiteMapPath
The code that controls and displays up to two parent links may be as follows:
<Asp: sitemappath id = "sitemappath1" runat = "server" parentlevelsdisplayed = "2"> </ASP: sitemappath>
Accessibility
The website navigation control is usually used on every page of the website. Screen readers and other auxiliary devices will read the text content in the navigation control loudly each time they access the page and each time they return the page.
IncludingSiteMapPath
,TreeView
, AndMenu
And other website navigation controls.SkipLinkText
Attribute, which can be skipped when retelling information is accessed by consecutive pages or duplicate pages.
Use accessible missing features
On the ASP. NET web page that contains the navigation control, add the following attributes to the control:
Skiplinktext = "skipped menu"
For exampleSiteMapPath
The control code may be as follows:
<Asp: sitemappath id = "sitemappath1" runat = "server" skiplinktext = "Skip breadcrumb"> </ASP: sitemappath>