sitemap,网站地图,在网站建设的时候是很有用的。它可以直接绑定在men和treeview控件上,还有一个指示当前路径的sitemappath控件,也可以直接绑定。
这是他常用的xml定义:
<sitemapnode url="course/group/grouplist.aspx" title="groupadmin" >
这个sitemap的权限已经和membership结合起来了,不同权限的用户所看到的地图已经被控制了。可以配置role属性来扩展例外的访问许可。注意,是例外的访问许可。
<sitemapnode url="course/tests/testlist.aspx" title="testadmin" role="student">这里有些介绍:http://zmsx.cnblogs.com/archive/2006/01/03/310381.aspx
简单的使用这里不作赘述,只是讨论一下怎么和扩展一下,让他可以访问资源时附带参数。
首先介绍这样一个资源:mysitemaptool:http://quitgame.cnblogs.com/archive/2005/11/24/283910.aspx
这位仁兄已经提供了一个工具,可以在程序中转发带参数的请求
比如: mysitemap.forward("details", "albumid={0}&page={1}", 1, 4);
确是简单实用。
现在想要的功能是:因为各个液面都需要不同的参数,所以在没有这些参数的情况下就禁止用户访问那个页面,转而访问父一级页面,递归。
首先,sitemap本身有个sitemapresolve事件,在当前路径被解析时触发,这是一段来自msdn的代码
private void page_load(object sender, eventargs e)
{
// the expandforumpaths method is called to handle
// the sitemapresolve event.
sitemap.sitemapresolve +=
new sitemapresolveeventhandler(this.expandforumpaths);
}
private sitemapnode expandforumpaths(object sender, sitemapresolveeventargs e)
{
// the current node represents a post page in a bulletin board forum.
// clone the current node and all of its relevant parents. this
// returns a site map node that a developer can then
// walk, modifying each node.url property in turn.
// since the cloned nodes are separate from the underlying
// site navigation structure, the fixups that are made do not
// effect the overall site navigation structure.
sitemapnode currentnode = sitemap.currentnode.clone(true);
sitemapnode tempnode = currentnode;
// obtain the recent ids.
int forumgroupid = getmostrecentforumgroupid();
int forumid = getmostrecentforumid(forumgroupid);
int postid = getmostrecentpostid(forumid);
// the current node, and its parents, can be modified to include
// dynamic querystring information relevant to the currently
// executing request.
if (0 != postid)
{
tempnode.url = tempnode.url + "?postid=" + postid.tostring();
}
if ((null != (tempnode = tempnode.parentnode)) &&
(0 != forumid))
{
tempnode.url = tempnode.url + "?forumid=" + forumid.tostring();
}
if ((null != (tempnode = tempnode.parentnode)) &&
(0 != forumgroupid))
{
tempnode.url = tempnode.url + "?forumgroupid=" + forumgroupid.tostring();
}
return currentnode;
}
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器