System.Web.UI.WebControls.Adapters

C

ciaran.mcauliffe

Hi all,
I have been playing with the
System.Web.UI.WebControls.Adapters.MenuAdapter class, I love how it
works and as with most things it does 99.9% of what I want it to do.
The .1% that I want may not be possible, this is where I need some
help.

What I want to do is have the adapter ignore some menu controls and
allow them to render normally, and with some other menu controls render
them in my special adapter format. I identify the controls which I want
rendered in a custom way (i.e. with the adapter's custom tags) by
placing an attribute on the them , and then within the overriden
functions in the adapter I do something like this:

protected override void RenderBeginTag(HtmlTextWriter writer)
{
if (IsValidForUse)
{
writer.WriteLine();
writer.WriteBeginTag("div");
writer.WriteAttribute("class", CSSClassName);
writer.WriteAttribute("id", CSSClassName);
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
}
else
{
base.RenderBeginTag(writer);
}
}

The IsValidForUse checks to see if the special attribute is present on
the control and if it is it will render the custom tags. The only
problem with this is, that when the IsValidForUse property returns
false and calls base.RenderBeginTag(writer); the menu control does not
render normally i.e. as if the adapter was not present, which is what I
want.

Does anyone know if this is possible?

Thanks in advance.
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top