asp.net 2.0中使用sitemapDATAsource做页面导航
来源:互联网 发布:类似好桌道的软件 编辑:程序博客网 时间:2024/04/30 03:20
在ASP.NET 2.0中,没有专门的页面导航控件,但可以使用SITEMAPdatasource配和DATALIST来实现。
SITEMAPDATASOURCE控件中,需要特别的建立一个web.sitemap的XML文件,该文件中存贮网站的结构,
比如
<?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="社区"/>
</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>
就可以实现简单的页面导航的效果了
- asp.net 2.0中使用sitemapDATAsource做页面导航
- asp.net 2.0中使用sitemapDATAsource做页面导航
- asp.net 2.0中使用sitemapDATAsource做页面导航
- asp.net 2.0中使用sitemapDATAsource做页面导航
- ASP.NET 2.0中使用sitemapdatasource页面导航控件
- ASP.NET 2.0中使用sitemapdatasource页面导航控件
- ASP.NET 2.0中使用sitemapdatasource页面导航控件
- asp.net2.0中使用sitemapDATAsource做页面导航
- 在ASP.NET 2.0中使用页面导航控件
- 在ASP.NET 2.0中使用页面导航控件
- 在ASP.NET 2.0中使用页面导航控件
- 在ASP.NET 2.0中使用页面导航控件
- ASP.NET 2.0中使用页面导航控件
- 在ASP.NET 2.0中使用页面导航控件
- 在ASP.NET 2.0中使用页面导航控件(原作)
- ASP.NET - SiteMapDataSource Web 服务器控件概述
- ASP.Net中使用Excel做报表
- 在ASP.NET2.0中使用页面导航控件
- TaskVision 解决方案概述:设计与实现
- 书籍下在,6天.11~17
- 破解中国软件业落后于印度的魔咒
- 数据库恢复实战
- 资料收集-JAVA代码编写的30条建议
- asp.net 2.0中使用sitemapDATAsource做页面导航
- 最恐怖的英语
- 自动归还的对象池--一个并不美丽的传说
- 进制转换
- lucene1.4.3 试用手记
- 设计一个图书借阅管理系统需要如何分析
- 发现Delphi 2005的几个小Bug
- API 應用
- 邮件服务器论坛精华帖(1)