The company project needs to add the navigation bar function of the topic, and naturally comes up with the sitemappath control (haha I prefer breadcrumb's breadcrumb name ). However, some links need to be opened in a new window because of project requirements. After searching for half a day, I didn't find that sitemappath can be set. It cannot be defined in Web. sitemap. But think about whether you can add this attribute when binding data. In fact, it's nothing more than HTML. Code . After trying to find OK.
First, define the Web. sitemap file (add the target attribute): <? XML version = "1.0" encoding = "UTF-8"?>
<Sitemap xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<Sitemapnode>
<Sitemapnode url = "~ /Sitemappath/default. aspx "Title =" Default display "Description = "" Target = "_ blank">
</Sitemapnode>
<Sitemapnode url = "~ /Sitemappath/Add target. aspx "Title =" add "Description =" "target =" _ blank ">
</Sitemapnode>
</Sitemapnode>
</Sitemap>
second, define the itemdatabound event of sizemappath: protected void sitemappath1_itemdatabound (Object sender, sitemapnodeitemeventargs e)
{< br> hyperlink hlk;
If (E. item. controls [ 0 ] Is hyperlink)
{
Hlk=(Hyperlink) E. Item. controls [0];
Hlk. attributes ["Target"]=E. Item. sitemapnode ["Target"];
}
}
Test: OK. In fact, other attributes can be added through this method. More results can be achieved. Here, it plays a role of throwing bricks. Haha!