Solved

asp:menu nodes not displaying properly with XML datasource

Posted on 2013-06-27
3
391 Views
Last Modified: 2013-07-22
Hi,

I am trying to use an XML datasource and an ASP:menu control to display the menu.
I have managed to get the SubMenu items showing and linking properly but am unable to get the first level node to display properly. At the moment, with the code I have, it shows MenuItem MenuItem MenuItem MenuItem etc. When I hover over the MenuItem that has the SubMenus they actually display and link properly. I believe I have tried adjusting the depth settings correctly and any thing else I have thought of. The reason I am using the XML datasource and XML file is because I want to have images displayed instead of words, sitemapdatasource doesn't allow that.

code :

XML file -
<?xml version="1.0" encoding="utf-8" ?>
<Menu>  
  <MenuItem text="Home" url="~/default.aspx"></MenuItem>
  <MenuItem text="Computer Services" url="~/pages/comp.aspx"></MenuItem>
  <MenuItem text="Home Technologies" url="~/pages/theatre.aspx"></MenuItem>
  <MenuItem text="Car Technology" url="~/pages/caraudio.aspx"></MenuItem>
  <MenuItem text="Shop" url="~/pages/shop.aspx"></MenuItem>
  <MenuItem text="Contact Us">
    <SubMenuItem text="Send Us A Message" url="~/pages/contactus.aspx"></SubMenuItem>
    <SubMenuItem text="About Us" url="~/pages/about.aspx"></SubMenuItem>
  </MenuItem>
</Menu>

Open in new window

--------------------------------------------------------

.aspx -
  <asp:XmlDataSource ID="XMLDatasource" runat="server" DataFile="~/MenuList.xml" XPath="/Menu/MenuItem"></asp:XmlDataSource>
                    <asp:Menu ID="MXMLMenu" runat="server" DataSourceID="XMLDatasource" IncludeStyleBlock="False" Orientation="Horizontal" >
                        <DataBindings>
                            <asp:MenuItemBinding DataMember="MenuItem" TextField="text" ValueField="text" 
                            NavigateUrlField="url" />
                            <asp:MenuItemBinding DataMember="SubMenuItem" NavigateUrlField="url" TextField="text"
                            ValueField="text" Depth="1" />
                        </DataBindings>
                    </asp:Menu>

Open in new window


I just keep getting errors saying can not bind to "url" check my bindings. These look the same as any I have come across on the web.

Please Help!
0
Comment
Question by:Thwom
  • 2
3 Comments
 
LVL 82

Expert Comment

by:hielo
Comment Utility
Try XPath="/Menu" instead of XPath="/Menu/MenuItem"
0
 

Accepted Solution

by:
Thwom earned 0 total points
Comment Utility
So, the solution is....

I had to have a url="" tag in the Contact Us menuitem! What a silly thing to have to do!
0
 

Author Closing Comment

by:Thwom
Comment Utility
Because I found the answer myself!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

7 Experts available now in Live!

Get 1:1 Help Now