?
Solved

Build Simple Menu using SiteMap

Posted on 2013-06-21
8
Medium Priority
?
531 Views
Last Modified: 2013-06-28
I have set  up a simple menu on a master page consisting of 3 choices,

Home, About Us, and Contact Us

There are no error messages.

The navigation url does not open when the menu item is clicked.

This is what I have:

Master Page:

          <asp:Menu ID="Menu1" runat="server"
                            DataSourceID="SiteMapDataSource1"
                            MaximumDynamicDisplayLevels="0" Orientation="Horizontal"
                           >
                            <DataBindings>
                                <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title" />
                            </DataBindings>
                        </asp:Menu>

                        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
                            ShowStartingNode="False" />


Web.sitemap:

<?xml version="1.0" encoding="utf-8" ?>
  <siteMap>
    <siteMapNode>
     
      <siteMapNode title="Home"  description="Home Page"
          url="~/Default.aspx">
      </siteMapNode>

      <siteMapNode title="About Us" description="History of StockPickerMax"
           url="~/About.aspx">
      </siteMapNode>

      <siteMapNode title="Contact Us" description="Contact Us"
            url="~/Contact.aspx">
      </siteMapNode>
   
    </siteMapNode>

  </siteMap>

What should I change?

Thank you
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Author Comment

by:Dovberman
ID: 39265403
The menu items display and are clickable.
0
 
LVL 13

Assisted Solution

by:Molnar István
Molnar István earned 300 total points
ID: 39265921
I think the problem is with the first and last  <siteMapNode>. I would try to delete them to see if works.

tutorial:
http://msdn.microsoft.com/en-us/library/yy2ykkab(v=vs.100).aspx

hope it helps
0
 
LVL 13

Assisted Solution

by:Jitendra Patil
Jitendra Patil earned 300 total points
ID: 39265959
try changing in you bindings as

<DataBindings>
            <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title" NavigateUrlField="url"  />
        </DataBindings>

hope this helps
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:Dovberman
ID: 39266286
I think the problem is with the first and last  <siteMapNode>. I would try to delete them to see if works.


Exactly one <siteMapNode> element is required directly inside the <siteMap> element.

NavigateUrlField="url"  // No change
0
 

Author Comment

by:Dovberman
ID: 39266377
The tutorials use two menus.  I tried this yesterday but found it confusing.
However, it has a possibility of working.

protected void Menu1_MenuItemClick(Object sender,    
      System.Web.UI.WebControls.MenuEventArgs e)
{
  switch(e.Item.Value)
  {
    case "Products":
      SiteMapDataSource2.StartingNodeUrl = "Default.aspx?node=hardware";
      return;
    case "Services":
      SiteMapDataSource2.StartingNodeUrl = "Default.aspx?node=consulting";
      return;
    case "Support":
      SiteMapDataSource2.StartingNodeUrl = "Default.aspx?node=drivers";
      return;
  }
}
0
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 300 total points
ID: 39266613
Why are you setting explicit dataBiding thing. Ideally just this should work:
 <asp:Menu ID="Menu3" runat="server"
                                DataSourceID="SiteMapDataSource1"
                                MaximumDynamicDisplayLevels="0" Orientation="Horizontal">
        </asp:Menu>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />

Open in new window

0
 

Accepted Solution

by:
Dovberman earned 0 total points
ID: 39268259
http://msdn.microsoft.com/en-us/library/16yk5dby(v=vs.100).aspx

I am following this article precisely.  The only difference is that the menu is on the master page.

I set it up on default.aspx, but the results were the same.

I recently discovered that the click event was not being fired.

   <asp:Menu ID="Menu1" runat="server"
            DataSourceID="SiteMapDataSource1"
            MaximumDynamicDisplayLevels="0" Orientation="Horizontal"
            OnMenuItemClick="Menu1_MenuItemClick">
            <DataBindings>
                <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title"
                    NavigateUrlField="url" NavigateUrl="~/Default.aspx" />
            </DataBindings>                  
           
        </asp:Menu>

=======

      protected void Menu1_MenuItemClick(Object sender,
          System.Web.UI.WebControls.MenuEventArgs e)
        {
            switch (e.Item.Value)
            {

                case "Products":
                    SiteMapDataSource2.StartingNodeUrl = "~/Site.Master?node=hardware";
                    return;
                case "Services":
                    SiteMapDataSource2.StartingNodeUrl = "~/Site.Master?node=consulting";
                    return;
                case "Support":
                    SiteMapDataSource2.StartingNodeUrl = "~/Site.Master?node=drivers";
                    return;
            }

        }
0
 

Author Closing Comment

by:Dovberman
ID: 39283765
Thanks for trying.  This got too complicated.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question