2.0: asp:Menu, asp:XmlDataSource, asp:PlaceHolder

R

R.A.M.

Hello,
I need your help with a problem of menu definition. Plase help, I have
little experience.

I have created custom Menu, which I want to put on a few .aspx pages:

public class DemoMenu : Menu
{
public DemoMenu(string ID, string DataSourceID)
: base()
{
this.ID = ID;
DataSourceID = DataSourceID;
StaticMenuItemStyle.BackColor = Color.LightBlue;
StaticMenuItemStyle.ForeColor = Color.Black;
StaticHoverStyle.BackColor = Color.Blue;
StaticHoverStyle.ForeColor = Color.White;
DynamicMenuItemStyle.BackColor = Color.LightBlue;
DynamicMenuItemStyle.ForeColor = Color.Black;
DynamicHoverStyle.BackColor = Color.Blue;
DynamicHoverStyle.ForeColor = Color.White;
}
}

in this way, for instance:

<form id="DemoForm" runat="server">
<asp:XmlDataSource ID="MenuDataSource" runat="server"
DataFile="App_Data/Menu.xml" />
<asp:placeHolder ID="MenuPlaceHolder" runat="server" />
</form>
....
protected void Page_Load(object sender, EventArgs e)
{
// Put custom menu:
DemoMenu menu = new DemoMenu("DemoMenu", "MenuDataSource");
MenuPlaceHolder.Controls.Add(menu);
}

I defined file Menu.xml in this way (XML is invalid I think, because I
could not find an example nor syntax description):

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Items>
<MenuItem Text="Files" Value="Files">
<MenuItem Text="Readinng text file" Value="ReadTXT"
NavigateUrl="~/ReadTXT.aspx" />
<MenuItem Text="Reading XML file" Value="ReadXML"
NavigateUrl="~/ReadXML.aspx" />
</MenuItem>
<MenuItem Text="Databases" Value="Databases">
<MenuItem Text="Selecting data using AccessDataSource"
Value="AccessDataSource" NavigateUrl="~/AccessDataSource.aspx" />
<MenuItem Text="Selecting data from MS Access"
Value="ReadMSAccess" NavigateUrl="~/ReadMSAccess.aspx" />
<MenuItem Text="Selecting data from SQL Server"
Value="ReadSQLServer" NavigateUrl="~/ReadSQLServer.aspx" />
</MenuItem>
</Items>

MY questions:
1. What is the correct Menu.xml contents? Is it described somewhere?
2. Menu is not displayed in a browser, there's nothing in HTML. Why?
Because of invalid Menu.xml? Other reasons?
(MenuPlaceHolder...Add() works fine.)

Thank you very much for your answers!
/RAM/
 
G

Guest

Hi,
If you want to use an XML file as your datasource for your sitemap, you
might as well use the SiteMapDataSource control and then just create a new
web.sitemap file. When you add the web.sitemap file to your projet it will
be pre configured with a valid XML template for you to use and then so long
as your datasourceID property for your menu control points at the
SiteMapDataSource control, it should all just work, with minimal
configuration. Also i don't really see the point of creating a class with
all those properties, just insert a menu control into you markup and define
it's properties.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

2.0: custom Menu as PlaceHolder 0
asp:Menu 3
asp:menu borders 2
asp:Menu weird top border problem 0
asp:menu cssclass? 2
using asp:menu to create drop down menu 2
ASP:Menu 0
How do I style the item in a asp:menu 0

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top