Solved

asp:menu nodes not displaying properly with XML datasource

Posted on 2013-06-27
3
392 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

947 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

19 Experts available now in Live!

Get 1:1 Help Now