System.Web.UI.WebControls.Adapters.MenuAdapter

Discussion in 'ASP .Net Web Controls' started by Dittrich, Jul 4, 2007.

  1. Dittrich

    Dittrich Guest

    I have a question about the System.Web.UI.WebControls.Adapters.MenuAdapter.

    I want to use the default asp.net 2.0 menu on my website, with one little
    addition. I want the rendered html to include an id-tag for each anchor (a)
    tag that is rendered by the menu control. My first thought was to use a
    browser file for this and define a menuadapter class in here. In the
    menuadapter class, override the RenderItem method to include the extra id
    tag. Something like this:

    public class MenuAdapter : System.Web.UI.WebControls.Adapters.MenuAdapter
    {
    public MenuAdapter() : base()
    {
    }

    protected override void RenderItem(HtmlTextWriter writer, MenuItem
    item, int position)
    {
    writer.AddAttribute("id", item.Value);
    base.RenderItem(writer, item, position);
    }
    }

    This doesn't work however. When I use a menuAdapter class, only the toplevel
    menu links are rendered, submenus don't pop out any more and the toplevel
    links include the word "Expand". When I look at the html rendered, I noticed
    a Webresource.axd file missing from the source.

    My question: Does anyone know of a good example of using a MenuAdapter
    class? One that is really simple (so not the one from the CSS friendly
    control adapters) which uses most of the original functionality? I can't
    seem to find much documentation on this subject.
    Dittrich, Jul 4, 2007
    #1
    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. Matt
    Replies:
    2
    Views:
    836
    Matt Getting
    Jul 24, 2003
  2. byrd48
    Replies:
    0
    Views:
    3,564
    byrd48
    Jul 6, 2006
  3. Dittrich
    Replies:
    0
    Views:
    428
    Dittrich
    Jul 4, 2007
  4. Andy B
    Replies:
    2
    Views:
    3,156
    Andy B
    Apr 23, 2008
  5. System.Web.UI.WebControls.Adapters

    , May 10, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    93
Loading...

Share This Page