System.Web.UI.WebControls.Adapters.MenuAdapter

D

Dittrich

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.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top