By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

2.0: custom Menu as PlaceHolder

P: n/a
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/
Mar 25 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.