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

x
?
Solved

asp:menu nodes not displaying properly with XML datasource

Posted on 2013-06-27
3
Medium Priority
?
402 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
[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
  • 2
3 Comments
 
LVL 82

Expert Comment

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

Accepted Solution

by:
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!
0
 

Author Closing Comment

by:Thwom
ID: 39345139
Because I found the answer myself!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

636 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