Solved

Build Simple Menu using SiteMap

Posted on 2013-06-21
8
500 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
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 100 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 12

Assisted Solution

by:jitendra patil
jitendra patil earned 100 total points
ID: 39265959
try changing in you bindings as

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

hope this helps
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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 100 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTPS jquery doesn't work 9 58
Capture logon name 13 70
EF5: Question about Metadata Artifact Processing 4 15
Please explain the parts of these 2 LINQ expressions 3 26
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now