I have an asp:Menu and it contains a top level menu item that points to http://www.example.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.example.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?
4 Answers
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.
-
Yeah, I know what you mean. I was using a sitemap as well. – Xaisoft Jan 19 '09 at 17:10
-
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 Dec 29 '09 at 19:25
-
The problem is that if you click the same menu link where you are to try to refresh the page, it doesn't refresh. any other solution? – Ronen Festinger Jun 16 '14 at 09:44
-
@Ronen: use a query string instead of the anchors, e.g. "one.aspx?x=y". Or use two different URLs and configure URL Rewriting so that both point to the same page. – M4N Jun 16 '14 at 12:29
-
Thanks, I finally did the solution using jquery. The query string solution you suggest has a problem as it's written here by Jade and also it will make problems when you concatenate other query strings and assume menu links has none so you add ? and not &. $(document).ready(function () { // refresh page when clicking menu item with current address $('#<%=aspMenu.ClientID%> a').click(function () { location.reload(); }); }); – Ronen Festinger Jun 16 '14 at 14:02
-
i found out it only worked on firefox, this is an improved solution: – Ronen Festinger Jun 18 '14 at 12:45
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?

- 26,785
- 5
- 80
- 117
I found out my solution in the comment above only worked on Firefox, this is an improved solution to make the page refresh even if you click on the same link as the current one but with an hash tag:
$(document).ready(function () { // refresh page when clicking menu item with current address $('#<%=aspMenu.ClientID%> a').click(function () {
var currentUrl = location.pathname;
var clickedUrl = $(this).attr('href');
if (currentUrl.indexOf('#') != -1 || clickedUrl.indexOf('#') != -1){
if (currentUrl.indexOf('#') != -1)
currentUrl = currentUrl.substring(0, currentUrl.indexOf('#'));
if (clickedUrl.indexOf('#') != -1)
clickedUrl = clickedUrl.substring(0, clickedUrl.indexOf('#'));
if (currentUrl == clickedUrl)
location.reload();
}); });
Or even better: removing the anchors with the digits from the hrefs on document ready:
$(document).ready(function () {
$('#<%=aspMenu.ClientID%> a').each(function () {
var re = /#\d/
var url = $(this).attr('href');
$(this).attr('href', url.replace(re, ""));
});
});

- 2,260
- 1
- 23
- 32
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" />

- 32,487
- 24
- 164
- 258
-
Using a query string will cause the selected class to not be added to the submenu elements. – Jared Dec 29 '09 at 19:26