本文整理汇总了C#中System.Web.SiteMapNode类的典型用法代码示例。如果您正苦于以下问题:C# SiteMapNode类的具体用法?C# SiteMapNode怎么用?C# SiteMapNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SiteMapNode类属于System.Web命名空间,在下文中一共展示了SiteMapNode类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSiteMapData
// The LoadSiteMapData() method loads site navigation
// data from persistent storage into a DataTable.
DataTable siteMap = LoadSiteMapData();
// Create a SiteMapNodeCollection.
SiteMapNodeCollection nodes = new SiteMapNodeCollection();
// Create a SiteMapNode and add it to the collection.
SiteMapNode tempNode;
DataRow row;
int index = 0;
while (index < siteMap.Rows.Count)
{
row = siteMap.Rows[index];
// Create a node based on the data in the DataRow.
tempNode = new SiteMapNode(SiteMap.Provider,
row["Key"].ToString(),
row["Url"].ToString());
// Add the node to the collection.
nodes.Add(tempNode);
++index;
}
示例2: LoadSiteMapFromStore
protected virtual void LoadSiteMapFromStore()
{
string pathToOpen;
lock (this)
{
// If a root node exists, LoadSiteMapFromStore has already
// been called, and the method can return.
if (rootNode != null)
{
return;
}
else
{
pathToOpen = HttpContext.Current.Server.MapPath("~" + "\\" + sourceFilename);
if (File.Exists(pathToOpen))
{
// Open the file to read from.
using (StreamReader sr = File.OpenText(pathToOpen))
{
// Clear the state of the collections and rootNode
rootNode = null;
siteMapNodes.Clear();
childParentRelationship.Clear();
// Parse the file and build the site map
string s = "";
string[] nodeValues = null;
SiteMapNode temp = null;
while ((s = sr.ReadLine()) != null)
{
// Build the various SiteMapNode objects and add
// them to the ArrayList collections. The format used
// is: URL,TITLE,DESCRIPTION,PARENTURL
nodeValues = s.Split(',');
temp = new SiteMapNode(this,
HttpRuntime.AppDomainAppVirtualPath + "/" + nodeValues[0],
HttpRuntime.AppDomainAppVirtualPath + "/" + nodeValues[0],
nodeValues[1],
nodeValues[2]);
// Is this a root node yet?
if (null == rootNode &&
string.IsNullOrEmpty(nodeValues[3]))
{
rootNode = temp;
}
// If not the root node, add the node to the various collections.
else
{
siteMapNodes.Add(new DictionaryEntry(temp.Url, temp));
// The parent node has already been added to the collection.
SiteMapNode parentNode =
FindSiteMapNode(HttpRuntime.AppDomainAppVirtualPath + "/" + nodeValues[3]);
if (parentNode != null)
{
childParentRelationship.Add(new DictionaryEntry(temp.Url, parentNode));
}
else
{
throw new Exception("Parent node not found for current node.");
}
}
}
}
}
else
{
throw new Exception("File not found");
}
}
}
return;
}