By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

Exception using sitemap class

P: n/a
I am writing a custom control (code see below) and I am getting an
exception that drives me crazy.

When I drag my control on a form, Visual Studio shows immediately the
following exception:

"Error Rendering Control - NiftyMenu1 An unhandled exception has
occurred. The provider 'AspNetXmlSiteMapProvider' specified for the
defaultProvider does not exist in the providers collection."

What does that mean exactly? For debugging purpoes I list my providers
with the following code:

<%@ Page Language="C#" %>
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server"&gt;
private void Page_Load(object sender, System.EventArgs e)
{

IEnumerator providers = SiteMap.Providers.GetEnumerator();
while (providers.MoveNext())
{
Response.Write(providers.Current);
}
}

I am getting the output: System.Web.XmlSiteMapProvider

So I think it should find it. Or is it System.Web.XmlSiteMapProvider
different to AspNetXmlSiteMapProvider?

What am I missing? Must be something obvious but I can't see it.

Any help is very much appreciated.



Here is the code of my control:

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Text;
5 using System.Web;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8
9 namespace MyControls
10 {
11 [ToolboxData("&lt;{0}:NiftyMenu
runat=server></{0}:NiftyMenu>")]
12 public class NiftyMenu : WebControl
13 {
14 protected override void RenderContents(HtmlTextWriter
output)
15 {
16 RenderMasterMenu(output);
17 }
18
19 protected virtual void RenderMasterMenu(HtmlTextWriter
output)
20 {
21 output.Write("&lt;ul id=\"nav\"&gt;");
22 // The following line produces the exception
23 SiteMapNode node = SiteMap.CurrentNode;
24 }
25 }
26 }

The offending line is #23. If I comment that out the exception is
gone. But I need the SiteMap class!

Oct 27 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.