ASP.NET CheckBox - rendering not compatible with WAI.

събота, 14 юли 2007 г.

What is WAI?
WAI stands for Web Accessibility Initiative. It's an attempt of W3C to improve the accessibility of WWW with different user agent devices which is especially important for people with physical disabilities. WAI is an number of guidelines that can help to make WWW more accessible. For more information look at here.

What is the problem with CheckBox control in ASP.NET?
The problem is that WAI suggests that controls such as text boxes, images, buttons etc. must have tooltips. So when you add a ToolTip property of a asp:CheckBox control, ASP.NET renders wrapping span and set's the tooltip to the span. But as I mentioned above WAI requires an alt(title) tag for every INPUT and when you try to validate a page with a checkbox the validation will fail.

How we can fix this?
As my friend and colleague Stefan Dobrev recently rightly pointed, Microsoft ASP.NET Team done their work excellent and in ASP.NET 2.0 they have provided very elegant solution for such problems - Control Adapters. (For more information about the architecture of control adapters look at this post)

To use control adapter, we have to create the standard folder named App_Browsers and in it we have to add a file with extension .browser - the so called Browser definition file. This is the content of the file in my example:



In the file we add section in which we add an adapter for control of type System.Web.UI.WebControls.CheckBox and we associated the adapter CheckBoxCtrlAdapter which is defined as below:


Thus all of the checkboxes in your page will render WAI compatible.

Conclusion
For many people WAI is very restrictive and in some ways hard achievable and even unnecessary. I think that at least easily achievable features should be observed. The future will show whether WAI will become a wide spred standard.

1 коментара:

Martin Kulov каза...

Very interesting topic. Keep up the good work!

 
Vesko Kolev's Blog : IDeveloper -