Solved

Build Simple Menu using SiteMap

Posted on 2013-06-21
8
482 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

15 Experts available now in Live!

Get 1:1 Help Now