中国站长下载-为中国站长提供最好最全的建站资源! 首 页发布资源有事留言繁體中文
设为首页
加入收藏
联系我们
 
您当前的位置:中国站长下载 -> 文章中心 -> 网页编程 -> .NET编程 -> 文章内容  虚拟主机 域名注册 退出登录 用户管理
栏目导航
· ASP编程 · .NET编程
· PHP编程 · JSP编程
· CGI 专区
热门文章
· sndvol32 - sndvol3...
· [组图] FLASH:《大话李白》...
· 个人网站到底能赚多...
· [图文] Rundll.exe是病毒吗...
· [组图] Flash:制作MV
· 价值12万元的网站SE...
· 网站创业者,你需要...
· 一个成功的网站设计...
· [图文] FLASH:韩国导航条解...
· 中国网站的赚钱模式...
相关文章
· 使用ASP.NET开发移动...
· 使用ASP.NET中的一点...
· 使用ASP.NET程序来管...
· [组图] 使用ASP.NET 2.0中的...
· [组图] 使用ASP.NET 2.0中的...
· 使用asp.net2.0中的...
· 使用asp.net进行多关...
· 使用asp.net2.0中的...
· 使用ASP.NET Atlas ...
· 使用ASP.NET Atlas ...
使用asp.net2.0中的SiteMap中的一些问题(1)
作者:不详  来源:不详  发布时间:2006-8-14 8:51:15  发布人:chinazhan

 减小字体 增大字体

     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;
  }
  
  
    做人要厚道,请注明转自chinazhan中国站长(www.ChinaZhan.com)。

 
[] [返回上一页] [打 印] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
中国站长下载
中国站长下载

本页只接受PR>=4 IT类站点连接,申请连接,谢谢您们的支持!希望我们的下载站能够真正帮到中国的站长们!
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图
Copyright © 2005-2006 ChinaZhan.Net. All Rights Reserved .