views:

921

answers:

4

Hello,

I have an asp:Menu and it contains a top level menu item that points to http://www.abc.com/one.aspx. When you hover over the top level menu item, it shows a dropdown and one of the selections is One which points to http://www.abc.com/one.aspx. Apparently, I can't do this, so I have been putting a ? at the end of the second url to get around this. I was curious as to if it is possible to have two of urls pointing to the same location in an asp:Menu?

+6  A: 

I had the same problem and used a slight variation of your solution: I added anchors to the URL, e.g:

BTW: I was using a sitemap file, and when you add to nodes with the same URL to that file, then the error/exception is pretty clear:

Multiple nodes with the same URL '/WebSite1/MyPage.aspx' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs.

So I guess it really is not possible to have to identical URLs.

M4N
Yeah, I know what you mean. I was using a sitemap as well.
Xaisoft
I wanted to comment and say that this solution is better than one where people add a query string to the end of the url. Adding an anchor keeps the generated classes correct when using CSS to style the menu. If you use a query string, then the classes won't be placed on the submenu item.
Jared
+2  A: 

I don't believe so.

The Menu control uses each item's NavigateUrl property as the identifier for highlighting and expanding the menu correctly - if you have two nodes with the same URL, how will the control know which one to highlight?

Zhaph - Ben Duguid
A: 

You can attach a query string variable that changes e.g.

<siteMapNode url="~/UnderConstruction.aspx?x=1" title="Customer"  description="Customer" />
<siteMapNode url="~/UnderConstruction.aspx?x=2" title="User"  description="User" />
<siteMapNode url="~/UnderConstruction.aspx?x=3" title="Area"  description="Area" />
<siteMapNode url="~/UnderConstruction.aspx?x=4" title="Well"  description="Well" />
<siteMapNode url="~/UnderConstruction.aspx?x=5" title="Build Report"  description="Build" />
Using a query string will cause the selected class to not be added to the submenu elements.
Jared
A: 

I just add an extra slash to the second URL.

For example,

Second instance of URL would look something like this:

http://www.yoursite.com/pages//default.aspx

The browser doesn't know the difference, but it's enough of a change that the sitemap does see a difference and not an identical URL.