views:

269

answers:

3

I have a site that I've tried to make compliant to XHTML 1.0 Strict. The doctype has been declared accordingly and I've set the web.config with the following:

  <system.web>
    <xhtmlConformance mode="Strict"/>
  </system.web>

My problem now lies here. I have a BulletedList server control whose DisplayMode is set to BulletedListDisplayMode.HyperLink.

This control is populated with entries from a web.sitemap xml file the first of which is disabled (enabled set to false in code behind). This consequently outputs an anchor tag with a disabled attribute. However, this is not compliant.

<ul id="example">
    <li class="first"><a disabled="disabled">test1</a></li>
    <li><a href="#">test2</a></li>
</ul>

When I validate this against the W3 validator, it fails because of this. Is this is bug? Given the set xhtml conformance, I would have expected the anchor tag to not have rendered at all.

I am simply trying to make the first item in the list to appear as plain text rather than a disabled link. Any suggestions?

A: 

You could always extend the BulletedList control and re-implement that part appropriately.

Noon Silk
Unfortunately, I'm not sure how to do that. Would you be able to provide an example?
I don't know off the top of my head; I would potentially use Reflector to check the source of that class, see where it does that type of rendering, then re-implement it to do it your way in your base class.
Noon Silk
A: 

The problem is really that the disabled attribute should not be applied to an anchor tag -- only to a handful of input elements, like a button.

Have you tried modifying your css style for an anchor tag within a list item with class "first?"

Jay
It'll still be clickable.
Noon Silk
Yes, I previously had it like that but because it was still clickable, I tried this and it was then noticed it failed the validator.
A: 

I'm headed to bed, but I'm going to snipe at this one to give you a possible starting point.

You could do as silky says above, and override OnRender, or you could see if you can accomplish you task with a System.Web.UI.Adapters.ControlAdapter and a browser file. The drawback of the ControlAdapter is that it'll be site wide.

Darthg8r