选择显示字体大小

使用asp.net2.0中的sitemap中的一些问题(1)

     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   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons