SiteMapPath基本用法
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SiteMa pPath基本用法
使用Si teMap Path之前必须先建立站点地图,因为Si teMap Path控件要依赖站点地图才能显示
开始=>新键一个Web.site map站点地图
如下代码:
<?xml v ersio n="1.0" en codin g="ut f-8"?>
<site Map x mlns="http://sc hemas.micr osof/AspNe t/Sit eMap-File-1.0">
<!--表示根目录的页面-->
<!--如果根目录有其它页面的话,请在同级目录下写配置
例如: <si teMap Node url="~/De fault.aspx" tit le="H ome" desc ripti on="主页"
re sourc eKey="主键"/>
子目录的有页面话,做如下配置例如:
<sit eMapN ode url="~/Def ault.aspx" titl e="Ho me" descr iptio n="主页" res ource Key="主键">
<siteM apNod e url="~/t emp/i ndex.aspx" titl e="in dex"
descr iptio n="in dexpa ge" r esour ceKey="ind ex" />
</si teMap Node>
在子目录中的子目录有页面话,做如下配置例如:
<siteM apNod e ur l="~/Defau lt.as px" t itle="Home" de scrip tion="主页"
resou rceKe y="主键">
<si teMap Nodeurl="~/tem p/ind ex.as px" t itle="inde x" de scrip tion="inde xpage"
res ource Key="index" >
<site MapNo de ur l="~/temp/temp2/show.aspx" tit le="s how"
descr iptio n="sh ow" r esour ceKey="sho w" />
</sit eMapN ode>
</site MapNo de>
就是同目录下的页面配置要保持目录一致
-->
<s iteMa pNode url="~/D efaul t.asp x" ti tle="Home" des cript ion="主页
" r esour ceKey="主键">
<sit eMapN ode u rl="~/inde x.asp x" ti tle="index" des cript ion="index page"
reso urceK ey="测试1" />
<sit eMapN ode u rl="~/temp/test001.a spx"title="ind ex22" desc ripti on="i ndexp age2" reso urceK ey="测试2" />
<sit eMapN ode u rl="~/temp/test002.a spx"title="002" des cript ion="002"resou rceKe y="测试3" />
<site MapNo de ur l="~/temp/Defau lt001.aspx" tit le="测试" de scrip tion="测试"
resou rceKe y="测试">
<siteM apNod e url="~/s ell/新文件夹1/Defau lt001.aspx" tit le="x ue" d escri ption="xue" res ource Key="xue">
</site MapNo de>
</siteM apNod e>
</s iteMa pNode>
</site Map>
使用“S iteMa pPath”控件无需代码和绑定数据就能创建网站导航。
此控件可自动读取和呈现网站图信息。
Web.s itema p 导航X ML文件
<?x ml ve rsion="1.0" enc oding="utf-8" ?>
<siteM ap xm lns="http://sch emas.micro soft.com/A spNet/Site Map-F ile-1.0" >
<s iteMa pNode titl e="首页" url="Sit eMapT est.a spx">
<siteM apNod e tit le="产品" ro les="*">
<sit eMapN ode t itle="Wind ows"url="SiteM apTes t.asp x?id=windo ws" />
<siteM apNod e tit le="O ffice" url="Sit eMapT est.a spx?i d=off ice"/>
<site MapNo de ti tle="Mobil e Dev ices" url="Site MapTe st.as px?id=mobi le" />
<siteM apNod e tit le="B usine ss So lutio ns" u rl="S iteMa pTest.aspx?id=b usine ss" />
<siteM apNod e tit le="S erver s" ur l="Si teMap Test.aspx?id=se rvers" />
<si teMap Nodetitle="Dev elope r Too ls" u rl="S iteMa pTest.aspx?id=t ools" />
<sit eMapN ode t itle="Game s and XBox" url="Sit eMapT est.a spx?i d=gam es" />
<siteM apNod e tit le="A ll Pr oduct s" ur l="Si teMap Test.aspx?id=al l" />
</siteM apNod e>
<site MapNo de ti tle="资源" r oles="*">
<si teMap Nodetitle="支持" role s="*">
<siteM apNod e tit le="修改密码"url="~/Log in/Ch angeP asswo rd.as px" />
<siteM apNod e tit le="K nowle dge B ase"url="SiteM apTes t.asp x?id=knowl edge" />
</si teMap Node>
<s iteMa pNode titl e="Do wnloa ds" u rl="S iteMa pTest.aspx?id=d ownlo ads"/>
<site MapNo de ti tle="Windo ws Up date" url="Site MapTe st.as px?id=wind owsup date" />
<sit eMapN ode t itle="Offi ce Up date" url="Site MapTe st.as px?id=offi ceupd ate"/>
<site MapNo de ti tle="Learn ing T ools">
<siteM apNod e tit le="T raini ng &Certi ficat ion"url="SiteM apTes t.asp x?id=train ing"/>
<site MapNo de ti tle="Books" url="Sit eMapT est.a spx?i d=boo ks" />
<siteM apNod e tit le="E vents & We bcast s" ur l="Si teMap Test.aspx?id=ev ents" />
<sit eMapN ode t itle="Patt erns& Pra ctice s" ur l="Si teMap Test.aspx?id=pa ttern s" />
</siteM apNod e>
<site MapNo de ti tle="Commu nity" url="Site MapTe st.as px?id=comm unity" />
<si teMap Nodetitle="Sec urity" url="Sit eMapT est.a spx?i d=sec urity" />
</s iteMa pNode>
<siteM apNod e tit le="R SS" r oles="*">
<si teMap Nodetitle="公司关系" ur l="Si teMap Test.aspx?id=re latio ns" />
<siteM apNod e tit le="R SSSit e" ur l="~/RSS/R SSSit e.asp x" />
<s iteMa pNode titl e="Ca reers" url="Sit eMapT est.a spx?i d=car eers" />
<sit eMapN ode t itle="Abou t thi s Sit e" ur l="Si teMap Test.aspx?id=ab out"/>
</sit eMapN ode>
</s iteMa pNode>
</site Map>
Web.site map文件必须包含根结点sit emap。
一张站点地图由一系列相联系
的S iteMa pNode对象组成。
这些Sit eMapN ode以一种层次方式联系在一起。
该层次包含单个根结点-它是该层中唯一的一个没有父结点的结点,代表首页。
在该
父s itema pnode结点下,可以有若干个子site mapno de结点,分别按层次结构代表了网站的各子栏目(留意一下上例中,各个子结点之间的包含关系)。
创建一个模板,这样保证每个页面都可以引用,看到web map..
然后在模板中添加控件:
<a sp:Si teMap PathID="S iteMa pPath1" ru nat="serve r"
Re nderC urren tNode AsLin k="tr ue" S howTo olTip s="tr ue" C ssCla ss
="sitem ap"></asp:SiteM apPat h>
1、添加一个网站地图项 Web.sitem ap项
2、在W eb.si temap项的写法如下:
<?xmlversi on="1.0" e ncodi ng="u tf-8"?>
<siteM ap xm lns="http://sch emas.micro soft.com/A spNet/Site Map-F ile-1.0">
<sit eMapN ode u rl="d efaul t.asp x" ti tle="首页" d escri ption="">
<site MapNo de ur l="Su pply.aspx" titl e="产品信息" d escri ption="" >
<s iteMa pNode url="prod uctde tails.aspx" tit le="产品详细信息" des cript ion="" /></sit eMapN ode>
<sit eMapN ode u rl="r egist er.as px" t itle="新用户注册"/>
<site MapNo de ur l="De mand.aspx" titl e="产品信息" d escri ption="">
</si teMap Node>
<sit eMapN ode u rl="P rojec ts.as px" t itle="招投标信息" de scrip tion="">
<sit eMapN ode u rl="D ownLo ad.as px" t itle="相关表格下载" d escri ption="" />
<siteM apNod e url="Pro jectI nfor.aspx" titl e="招投标详细信息" des cript ion="" /></sit eMapN ode>
<site MapNo de ur l="ne wsfro nt.as px" t itle="新闻"descr iptio n="">
<s iteMa pNode url="news_deta il.as px" t itle="行业资讯详细信息" desc ripti on="" />
<sit eMapN ode u rl="c ompan y_det ails.aspx" titl e="会员展厅详细信息"
de scrip tion="" />
<s iteMa pNode url="Manu scrip tFron t.asp x" ti tle="在线投稿" desc ripti on="" />
<sit eMapN ode u rl="s ubjec t_det ail.a spx"title="专题栏目详细信息" des cript ion="" />
<si teMap Nodeurl="exper tinte rview_deta il.as px" t itle="人物专访详细信息"
desc ripti on="" />
</site MapNo de>
<siteM apNod e url="For eTrai n.asp x" ti tle="培训咨询" desc ripti on="">
<siteM apNod e url="Tra inInf or.as px" t itle="培训详细信息" d escri ption="" /> <siteM apNod e url="Bus iHand Book.aspx" titl e="商务手册" d escri ption="" /> <siteM apNod e url="Tec hnolo gy.as px" t itle="技术咨询" des cript ion="">
<si teMap Nodeurl="TechI nfor.aspx" titl e="技术信息" d escri ption=""/>
</siteM apNod e>
<site MapNo de ur l="Ex pert.aspx" titl e="专家顾问团"descr iptio n=""/>
</siteM apNod e>
<s iteMa pNode url="Exhi bitFr ont.a spx"title="机电信息展览馆" desc ripti on=""> <siteM apNod e url="exh ibit_detai l.asp x" ti tle="会展详细信息" de scrip tion=""/></sit eMapN ode>
</si teMap Node>
</s iteMa p>
3、在web.conf ig文件中的配置如下:
<s ystem.web>
<si teMap defa ultPr ovide r="Xm lSite MapPr ovide r" en abled="tru e">
<pro vider s>
<ad d nam e="Xm lSite MapPr ovide r"
desc ripti on="S iteMa p pro vider whic h rea ds in .sit emapXML f iles."
type="Syst em.We b.Xml SiteM apPro vider, Sys tem.W eb, V ersio n=2.0.0.0, Cult ure=n eutra l, Pu blicK eyTok en=b03f5f7f11d50a3a"
s iteMa pFile="web.site map"/>
</prov iders>
</s iteMa p>
</syst em.we b>
4、在页面需要网站地图的位置放入SiteM apPat h控件,设置Site MapPa th的Si teMap Provi der属性为conf ig文件中的name的值:Xm lSite MapPr ovide r 即完成网站地图的制作
。