How to use FindSiteMapNodeFromKey(string) Asp.net? Not working

JackBauer

New Member
I need to retrieve some specific URL's in a lot of places of different webfiles. So I start to build a sitemap in XML format. I don't need navigation menu, or breadcrumbs, just simply get the URL by the resourcekey. Unfortunately all readings so far just explain how to set up a navigation menu. And all I've tried so far just has take me to errors.I need something like this, (but throws: Object reference not set to an instance of an object. And also Mynode1 is always null):\[code\]SiteMapNode MyNode1 = new SiteMapNode(MyXmlSiteMapProvider, "Product1");HyperLink1.NavigateUrl = MyNode1.Url;\[/code\]I also do this:\[code\] SiteMapNode MyNode1 = new SiteMapNode(MyXmlSiteMapProvider, "Product1"); MyNode1= MyXmlSiteMapProvider.FindSiteMapNodeFromKey("Product1"); HyperLink1.NavigateUrl = MyNode1.Url;\[/code\]I also try with the NameValueCollection and providerAttributes to Initialize MyXmlSiteMapProvider and then BuildSiteMap(), but the same result. (blank link, or error)My sitemap looks like this (the filename is web.sitemap)\[code\]<?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="~/default.aspx" title="Home" description="Homepage" resourceKey="home"> <siteMapNode url="~/products/mainlist.aspx" title="List of products" description="" resourceKey="listOfProducts" > <siteMapNode url="~/products/catA/someproduct.aspx" title="Product tittle" description="" resourceKey="Product1"/> </siteMapNode> </siteMapNode></siteMap> \[/code\]My Web.Config file, have this \[code\]<siteMap defaultProvider="XmlSiteMapProvider" enabled="true"> <providers> <add name="XmlSiteMapProvider" description="SiteMap provider that reads in .sitemap files." type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" /> </providers> </siteMap>\[/code\]Thanks in advance to anyone that knows a simple way to make this work.
 
Back
Top