2.0: custom Menu as PlaceHolder

R

R.A.M.

Hello,
I need your help with a problem concerning Menu control.
Could you help me please?

I have created custom Menu:

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;
}
}

which I try to use on .aspx page:

<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);
}

My Menu.xml file I have defined this way (I don't think it's correct
but I couldn't find an example):

<?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 are:
1. How to write XML for my menu correctly?
2. Menu is not displayed in browser, there's nothing in HTML about my
menu. Why? Because of invalid XML? Other reasons?
(MenuPlaceHolder...Add() works fine.)

Thank you very much for your answers!
/RAM/
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top