欢迎访问我的博客 https://javascript.shop

net5:动态修改内存中的站点地图节点

原文发布时间为:2008-07-29 —— 来源于本人的百度文章 [由搬家工具导入]

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class sitemap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SiteMap.SiteMapResolve+=new SiteMapResolveEventHandler(SiteMap_SiteMapResolve);
    }
    SiteMapNode SiteMap_SiteMapResolve(object sender,SiteMapResolveEventArgs e)
    {
        SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
        SiteMapNode tempNode=currentNode;
        int id=nid();
        int page=npage();

        if (id > 0)
        {
            tempNode.Url = tempNode.Url + "?id=" + id.ToString();
        }
        if (id > 0 && page >= 0)
        {
            tempNode.Url = tempNode.Url + "&page=" + page.ToString();
        }
        else if (page >= 0)
        {
            tempNode.Url = tempNode.Url + "?page=" + page.ToString();
        }
        return tempNode;
    }

    private int nid()
    {
        return 2;
    }
    private int npage()
    {
        return 3;
    }

}

posted @ 2017-07-09 15:04  孑孓子  阅读(98)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop