国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net 2.0中使用sitemapDATAsource做頁面導(dǎo)航

2024-07-10 13:03:02
字體:
供稿:網(wǎng)友
在asp.net 2.0中,沒有專門的頁面導(dǎo)航控件,但可以使用sitemapdatasource配和datalist來實(shí)現(xiàn)。
sitemapdatasource控件中,需要特別的建立一個(gè)web.sitemap的xml文件,該文件中存貯網(wǎng)站的結(jié)構(gòu),
比如
<?xml version="1.0" encoding="utf-8" ?>

<sitemap xmlns="http://schemas.microsoft.com/aspnet/sitemap-file-1.0" >

<sitemapnode url="default.aspx?id=-1" title="首頁">

<sitemapnode url="default2.aspx?id=0" title="商品"/>

<sitemapnode url="default3.aspx?id=1" title="社區(qū)"/>

</sitemapnode>

</sitemap>
之后,在default.aspx中,寫入代碼:
<%@ page language="c#" %>



<script runat=server>



protected void page_load()

{

int index = -1;

int32.tryparse(request.querystring["id"], out index);



tabs.selectedindex = index;

}



</script>



<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="head1" runat="server">

<title>untitled page</title>

<style>

a

{

color: #000000;

text-decoration: none;

}



.mytab

{

background: #6666ff;

padding: 4px;

}



.mytabselected

{

background: #ff00ff;

padding: 4px;

}

</style>



</head>

<body>

<form id="form1" runat="server">

<div>



<table>

<asp:datalist repeatdirection=horizontal id="tabs" runat="server" datasourceid="sitemapdatasource1">

<itemtemplate>

<td width="4" height="20" valign="top" nowrap class="mytab">

<a href='<%# eval("url") %>'><%# eval("title") %></a>

</td>

</itemtemplate>

<selecteditemtemplate>

<td width="4" height="20" valign="top" nowrap class="mytabselected">

<a href='<%# eval("url") %>'><%# eval("title") %></a>

</td>

</selecteditemtemplate>

</asp:datalist>

</table>

<asp:sitemapdatasource showstartingnode=false id="sitemapdatasource1" runat="server" />

</div>

</form>

</body>

</html>


就可以實(shí)現(xiàn)簡單的頁面導(dǎo)航的效果了

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 荥阳市| 遂溪县| 九龙城区| 贵州省| 凤台县| 甘孜| 仲巴县| 铁岭市| 襄城县| 衡水市| 沐川县| 陇南市| 青龙| 棋牌| 奉贤区| 台南县| 汕尾市| 自治县| 盐城市| 呼图壁县| 耿马| 寻乌县| 临桂县| 金塔县| 隆尧县| 武邑县| 娄烦县| 甘肃省| 汉阴县| 安康市| 长乐市| 漠河县| 开鲁县| 西乌珠穆沁旗| 扶风县| 新余市| 许昌市| 萨迦县| 正蓝旗| 台东县| 蓝山县|