1

I am attempting to use a .sitemap file to build a menu in my site; however I am having a number of issues with the output.

Firstly, the table output wasn't nice - I downloaded the 'CSSFriendly' DLL (http://www.codeplex.com/cssfriendly).. This now gives the output in ul and li's ..

But I want the menu to be free of javascript or css that pops up levels one at a time etc.

I thought that for a start using the StaticDisplayLevels would resolve this, but it seems to ignore it and just output the first level, I then have to mouse over to get more menu options..

I suppose the long and short is: should people stay clear of menu controls and just write the markup themselves? If not and it isn't a horrible route to go down - How can I get rid of all the formatting and mouse over jazz.. I just want a whole menu, horizonally displayed (I can do this with my CSS though).

Thanks for any help, also apologies if this question seems garbled (its frustration). Pete

peteski
  • 1,455
  • 3
  • 18
  • 40

4 Answers4

2

I my experience the ASP.net menu can be tamed and it's not as bad as it may at first appear.

(I have tried to find some code for your static display level problem but can't access my SVN repository at the moment. However I have had the same problem and it's fairly easy to fix.)

Of course the MS menu is never going to be as neat as one you could write yourself in HTML, but it's great if you don't want to spend too long over it and you want to use all the SiteMapProvider stuff.

Just don't fall into the "everything MS provide is rubbish I'll have to write my own" trap, because it's really not that bad.

NeedHack
  • 2,943
  • 3
  • 30
  • 44
2

Pete,

I've dug out some of my old code, which uses the asp.net menu control. There's very little in there, setting StaticDisplayLevels to 2 and Orientation to "Horizontal" makes it all work fine. Most of the work is in skinning it (and there are a couple of hacks to highlight the current location if some of the urls differ only by querystring).

However, switch to use the CSS friendly adaptor and I get the exact same problems you describe (only the root item is shown and can't get to render horizontally).

Makes me wonder if the CSS friendly menu adaptor is broken? There are working examples for an old version of the code http://www.asp.net/CSSAdapters/Menu.aspx

Chris

NeedHack
  • 2,943
  • 3
  • 30
  • 44
1

I created a neat little sample project you can use at http://simplesitemenu.codeplex.com/

It is a composite control which generates a nested UL/LI listing from your sitemap.

Enjoy!

Mr W
  • 597
  • 1
  • 7
  • 22
1

peteski22,

I answered a similar question on jQuery Menu and ASP.Net Sitemap recently. I've summarised it again here:

Basically I used the <asp:Menu> control with a .sitemap file, added the CSSFriendly.DLL and CSSFriendlyAdapters.browser files (all of which you have done) to get the menu rendered as <ul><li>s...

AND THEN

...downloaded/added Superfish with jQuery (.js and .css files) and search-and-replaced in superfish.css to change the 'default' Superfish style with the one that the Menu control renders (eg. sf-menuAspNet-Menu).

jQuery is very cool - and 'recommended' by Microsoft.

You can 'view source' at conceptdevelopment.net to see it working... or download an example project with all the files you need.

(I am still trying to figure out how to get the Menu's default class changed, rather than the search-and-replace hack)

Community
  • 1
  • 1
Conceptdev
  • 3,261
  • 1
  • 21
  • 23