Templating and Accessibility

Download Report

Transcript Templating and Accessibility

SWL002
Templating and Accessibility
Alex Homer
Dave Sussman
Agenda
Ideas for Page Templating
Accessibility
Page Templating
Historically
Server Side Include
Currently
User Controls
Header.ascx
Footer.ascx
Templated Server Control
Control writes default content
User content within templates
<my:ContentControl runat="server">
<ContentTemplate>
Page content goes here
</ContentTemplate>
</my:ContentControl>
Problems With Templates
Controls within templates not accessible
at compile time
FindControl
Intellisense Support
Schema defining templates
Custom Server Control
Write default content
User content within server control
<my:ContentControl runat="server">
Page content goes here
</my:ContentControl>
Server Controls
Pros
Toolbox support
Drag and drop
Cons
No default designer support
Must build a ControlDesigner
Control has to be actively placed on form
Custom Page Template Class
Inherits from Page
Provides default content
Rendering content directly
Building a control collection
Load content from template page
Custom Template Class
using System.Web.UI;
namespace MyCompany
{
public class PageTemplate : Page
{
protected override void Render(HtmlTextWriter writer)
{
// render default content
}
protected override void CreateChildControls()
{
// generate default controls
}
}
}
Using a Custom Template
<%@ Page Inherits="MyCompany.PageTemplate" %>
public class MyPage : MyCompany.PageTemplate {
}
Public Class Page
Inherits MyCompany.PageTemplate
End Class
Direct Rendering
protected override void Render(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Width,
"100%");
writer.RenderBeginTag("table");
writer.RenderBeginTag("tr");
writer.RenderBeginTag("td");
writer.Write("some default header content");
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderBeginTag("tr");
writer.RenderBeginTag("td");
base.Render(writer);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
Direct Rendering
Pros
Quick
Cons
Must implement postback handling
Building a Control Collection
protected override void CreateChildControls()
{
TableCell tc = new TableCell();
TableRow tr = new TableRow();
Table t = new Table();
AddUserContent(tc);
tr.Controls.Add(tc);
t.Controls.Add(tr);
this.Controls.Add(t);
}
Building a Control Collection
protected void AddUserContent(TableCell tc)
{
foreach (Control c in this.Controls)
{
tc.Controls.Add(c);
this.Controls.Remove(c);
}
}
Building a Control Collection
protected ControlCollection _ctls;
protected override void AddParsedSubObject(Object obj)
{
if (ctls == null)
ctls = new ControlCollection();
ctls.Add((Control)obj);
}
protected void AddUserContent(TableCell tc)
{
foreach (Control c in _ctls)
tc.Controls.Add(c);
}
Building a Control Collection
Pros
Easier implementation of postback
just add events to controls
Cons
Slower than direct rendering
Custom Template Class
Pros
Simplicity
Cons
No designer support
User content should not include
HTML header
Server FORM
Custom Templates
Pros
Default Content
Default Implementation
Less work for developers
Good place to introduce accessiblity
Accessibility
Why ?
It's already "the law" in many countries
Test cases have already been won
You really should do it anyway...
How ?
Make full and proper use of HTML 4.x
Add a few simple "extra" elements
Test the pages yourself
The Law - USA
Section 508 Standards for Electronic and
Information Technology
http://www.access-board.gov/sec508/guide/
"Any organization or company that contracts
with the Federal government must ensure that
its website and electronic data are available
to the public in a manner that is accessible to
people with disabilities."
The meaning of the word "contracts" is
becoming more tenuous as time goes by...
The Law - Europe
In June 2000, the eEurope Action Plan 2002 was
adopted by the Feira European Council. One of
the specific targets of the action plan is to improve
access to the Web for people with disabilities and,
of course, to adopt and implement the results of
the Web Accessibility Initiative project.
"In Europe, we have now clearly established that
actions must be taken to identify and remove
these barriers. The European Commission is fully
committed to this goal."
The Law - UK
The Disability Rights Commission Act 1999
A Formal Investigation in 2003 into Website
Accessibility for Disabled People
systematic evaluation of the extent to which the current
design of websites ... facilitates or hinders use by
disabled people in England, Scotland and Wales
analysis of the reasons for any recurrent barriers
identified by the evaluation
recommendations for further work which will contribute
towards enabling disabled people to enjoy full access
to, and use of, the Web.
The Law - Australia
"Under the Federal Disability Discrimination Act as well as under equivalent laws in all Australian
States - it is unlawful to discriminate against a
person on the grounds of their disability by having
a website which they cannot access"
"The World Wide Web Consortium has developed
web access guidelines, and non-compliance with
them by the operators of Australian websites is in
breach of the Act"
Dr Sev Ozdowski, Acting Disability Discrimination Commissioner
"A Worldwide Precedence"
In Australia, in 1999/2000, Bruce Maguire (a blind person)
v Sydney Organizing Committee for the Olympic Games
Images on Olympics.com had no text equivalent for
screen readers and Braille displays
SOCOG failed to react to directives and fined A$20,000
Similar clauses in the Disability Discrimination Act, the
Americans with Disabilities Act, Canadian Human Rights
Act, provincial, state, and territorial human-rights codes
"The case of Maguire vs. SOCOG will inevitably come into
play as a precedent for legal cases worldwide."
The contenu.nu Content Consultancy, Toronto
Assisting Navigation - 1
Include a meaningful <title> element in
every page
Provide "skip to" links as the first items in
every page
Make the structural layout of every page
similar (if appropriate for the content)
Avoid self-referring links
Avoid meaningless text such as "click
here" in hyperlinks
Assisting Navigation – 2
Lay out the content of HTML tables so
they can be read from left to right (not
vertically) and still make sense
Use <th> elements for the heading row
Add a 'headers' or 'scope' attribute to
identify if the cell contains data that applies
to the row (scope="row") or column
(scope="col")
But .. hard to do with ASP.NET controls
Assisting Navigation – 3
Put the captions in the 'expected' places
on an HTML <form>
To the left of a textbox or list control
To the right of a radio button or checkbox
Use <label> elements on complex forms
Identifying Elements - 1
Include 'name' and 'title' attributes in all
<frame> elements and use <noframes>
Include 'title' attribute in interactive elements
<a>, <input>, <select>, <textarea>, etc.
Include 'alt' attribute in every image element
brief but meaningful text description of image
use the accepted "D" link for the description
include alt="" (an empty string) if image does
not contribute to page content
Identifying Elements - 2
Include an 'alt' attribute in every <area>
definition of a client-side image map
Avoid server-side image maps, which cannot
be described to users in any meaningful way
For important images/animated content use
the 'longdesc' attribute to point to a text file
or Web page that contains a full description
of the image
General Recommendations
Use generic font sizes such as "x-small" and
"large" - allows font to be enlarged
Provide alternative text content if possible
inside an <object> or <applet> element, but
outside any <param> elements
Don't generate content with client-side script
or use <noscript> section for alternative
content
Test Your Pages
Try accessing your pages in Lynx
see if they are usable in a text-only browser
Try accessing your site in a "page reader"
i.e. IBM Home Page Reader
Turn off your screen and see if you can
navigate through your own site!
Demonstrations
"Skip to" links and "D" links
Text Browsers and Page Readers
Resources
W3C Web Content Accessibility Guidelines
http://www.w3.org/TR/WAI-WEBCONTENT/
W3C Policy and Laws Guide by Country
http://www.w3.org/WAI/Policy/
Watchfire 'Bobby' Accessibility Test Tools
http://bobby.watchfire.com/
CAST
http://cast.org/products/
Community Resources
Community Resources
http://www.microsoft.com/communities/default.mspx
Most Valuable Professional (MVP)
http://www.mvp.support.microsoft.com/
Newsgroups
Converse online with Microsoft Newsgroups, including Worldwide
http://www.microsoft.com/communities/newsgroups/default.mspx
User Groups
Meet and learn with your peers
http://www.microsoft.com/communities/usergroups/default.mspx
SOFTWARE LEGENDS
Alex Homer & Dave Sussman
Meet the Authors Book signing
THURSDAY 3rd JULY at 14.15-15.00 hrs
evaluations
© 2003 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.