asp:menu nodes not displaying properly with XML datasource

Posted on 2013-06-27
Medium Priority
Last Modified: 2013-07-22

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" ?>
  <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>

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" >
                            <asp:MenuItemBinding DataMember="MenuItem" TextField="text" ValueField="text" 
                            NavigateUrlField="url" />
                            <asp:MenuItemBinding DataMember="SubMenuItem" NavigateUrlField="url" TextField="text"
                            ValueField="text" Depth="1" />

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!
Question by:Thwom
  • 2
LVL 82

Expert Comment

ID: 39324792
Try XPath="/Menu" instead of XPath="/Menu/MenuItem"

Accepted Solution

Thwom earned 0 total points
ID: 39325628
So, the solution is....

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

Author Closing Comment

ID: 39345139
Because I found the answer myself!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
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…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

587 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