Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Build Simple Menu using SiteMap

Posted on 2013-06-21
8
Medium Priority
?
535 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 free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

610 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