2

I have a menu for my site, using a sitemap file and role provider to generate the links based on role.

When the menu was created manually, the links looked like this:

Link1 | Link2 | Link3 | etc... 

now its on a hover type of menu which is what i don't want:

Link1
  |___ Link2___Link3
  |___ Link4

How can I get it to look as the first type?

My first time using sitemap for menu navigation so not too sure how to create the <siteMapNodes>

I assume its due to this:

<siteMapNode url="~/Reporting.aspx" title="Reporting" description="" roles="MyRole" > <siteMapNode url="~/Auditing.aspx" title="Auditing" description="" roles="MyRole"/> <siteMapNode url="~/TeamManager.aspx" title="Team Manager" description="" roles="MyRole"/> </siteMapNode>

7
  • This would require a bit of css knowledge, but you can view the source of your page to see which styles are used to produce that effect, and to override those styles to meet your needs.
    – Jeremy
    May 17, 2012 at 15:04
  • @Jeremy, what does css have in common with a structure of the menu? He obviously has some structure in his sitemap that creates a tree like this. Css won't help him really...
    – walther
    May 17, 2012 at 15:07
  • I already have a "menu" css setting which is actually set to the asp:menu object (and thats what it was used before, when it was displaying horizontally):
    – sd_dracula
    May 17, 2012 at 15:07
  • Can you show how you bind to that sitemap?
    – walther
    May 17, 2012 at 15:08
  • Yes I'm just not sure how to create a horizontal menu using this:<siteMapNode url="~/Reporting.aspx" title="Reporting" description="" roles="MyRole"> <siteMapNode url="~/Auditing.aspx" title="Auditing" description="" roles="MyRole"/> <siteMapNode url="~/TeamManager.aspx" title="Team Manager" description="" roles="MyRole"/> </siteMapNode>
    – sd_dracula
    May 17, 2012 at 15:08

2 Answers 2

4

A sitemap will nest items if the XML in the sitemap code is nested.

The following will show:
Link1 | Link2 | Link3

    <siteMapNode url="Link1Url" title="Link1" />
    <siteMapNode url="Link2Url" title="Link2" />
    <siteMapNode url="Link3Url" title="Link3" />

The following will show:
Link1
   |-Link2
   |-Link3

    <siteMapNode url="Link1Url" title="Link1">
        <siteMapNode url="Link2Url" title="Link2" />
        <siteMapNode url="Link3Url" title="Link3" />
    </siteMapNode>

Your full Web.sitemap will look something like the following:

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" enableLocalization="true" >
        <siteMapNode url="~/" title="Home">
            <siteMapNode url="Link1Url" title="Link1" />
            <siteMapNode url="Link2Url" title="Link2" />
            <siteMapNode url="Link3Url" title="Link3" />
        </siteMapNode>
    </siteMap>
7
  • that doesn't work I have tried it. I get error: Exactly one <siteMapNode> element is required directly inside the <siteMap> element.
    – sd_dracula
    May 17, 2012 at 15:15
  • You will need one "root" siteMapNode to house all the others. I'll update my examples to show the full document. (Edit complete)
    – CodeHxr
    May 17, 2012 at 15:16
  • any idea on how to fix this, seems like theres something very minor which we're missing
    – sd_dracula
    May 17, 2012 at 15:58
  • I'm not sure... this was an exact copy/paste off of what we're using with url and title values changed. How is yours different?
    – CodeHxr
    May 17, 2012 at 17:55
  • 1
    Got it: ShowStartingNode="False" fixes the problem.
    – sd_dracula
    May 18, 2012 at 12:05
0

I would also suggest to use a jQuery plugin to build up the navigation from the Site collection if you are using menu-kind structure.

1
  • I believe that is done automatically when the maste rpage is created.
    – sd_dracula
    May 17, 2012 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.