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

Discussion in 'ASP .Net' started by R.A.M., Mar 29, 2006.

  1. R.A.M.

    R.A.M. Guest

    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/
    R.A.M., Mar 29, 2006
    #1
    1. Advertising

  2. 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.

    "R.A.M." wrote:

    > 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/
    >
    >
    =?Utf-8?B?Y2xpY2tvbg==?=, Mar 29, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Sinclair

    ASP.Net 2 XMLDataSource

    Rob Sinclair, Feb 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    450
    Rob Sinclair
    Feb 17, 2005
  2. =?Utf-8?B?bWlrZQ==?=

    populate checkboxlist from XmlDataSource (ASP.net 2.0)

    =?Utf-8?B?bWlrZQ==?=, Aug 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,362
    =?Utf-8?B?bWlrZQ==?=
    Aug 18, 2005
  3. R.A.M.

    2.0: custom Menu as PlaceHolder

    R.A.M., Mar 25, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    389
    R.A.M.
    Mar 25, 2006
  4. Miro
    Replies:
    2
    Views:
    437
  5. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    325
Loading...

Share This Page