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