Solved

Build Simple Menu using SiteMap

Posted on 2013-06-21
8
518 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 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

696 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