Enable the ASP.NET Web site to be accessible
Release Date: 6/22/2004
| Update Date: 6/22/2004
Scott Mitchell
4Guysfromrolla.com
Applicable to: Microsoft ASP.NETMICROSOFT .NET Framework Microsoft Visual Studio.net
Summary: Use the inheritance mechanism in the .NET frame to extend the ASP.NET class to generate the ASP.NET code that the disabled person is fully accessible.
Download code example.
This page
Introduction WAI, WCAG and Section 508Microsoft Accessible ASP.NET Web Controls for ASP.NET 1.x Create an Adaptive Accessible DataGrid Web Control in ASP.NET web page ASP.NET Whidbey Accessibility related books
Introduction
Although most online users can browse the Web site with a web browser with typical browser settings, disabled users typically use alternative means to access online information. For example, blind people may use a plain text browser capable of converting text into a Braille, or use a screen reader to read the text. Users who decline their vision may still use browsers like Microsoft® Internet Explorer, but they need to use the screen magnifying glass or configured to use a large-size browser. Incounting inconvenience may hinder the user using a mouse or keyboard as an input device.
Because persons with disabilities typically use special equipment or non-standard browser configuration to browse the web, the overall design of the Web site and the HTML tag will greatly affect the user experience of the disabled. For example, if you use an absolute dimension (such as 10pt) to specify the font size, the screen will display the font in the absolute size instead of display the font relative to the text size configured in its browser. If the site has a Flash or ShockWave interface and does not provide an alternate text representation, it is actually accessible to users of the Braille or text to the voice synthesizer. If a Web site can be forwarded to the standby device, it is called "accessible".
At this moment you may be thinking: "Why do I make sure that my web site is accessible?" As far as I know, there are two very legitimate reasons:
1. This is a good business strategy - according to US Census 2000 survey, 49.7 million Americans have disabilities; Harris Interactive conducts investigations in June 2000 show that 43% of the United States disabled people are fixed online users, and Time for users with disabilities is almost twice that of users with disabilities. Combining these two surveys, you will find more than 12 million US disabled people frequently online. If you don't take some time to make your web site accessible, you will lose $ 21,1 million potential visitors. 2. This is a mandatory requirement of government agencies - In 1998, the US government passed the rehabilitation Act No. 508 (Section 508), requiring federal agencies to make its electronic information for disabled access. This decree provides accessibility guidelines for software applications and web applications and telecommunications products and video products. Not only the federal organizations need to implement accessibility guidelines, but also private companies that have worked with the federal government also need to implement this guideline. (In many countries other than the United States, there are similar accessibility requirements for government agencies.) So, if you work for the government or work to the government, you need to create accessible web applications.
In this article, we will discuss which steps you can take to make sure your Microsoft? ASP.NET Web site is accessible. We will briefly check the current official accessibility guidelines and focus on discussing accessibility guidelines used by the US government. This article will finally discuss how to use the inheritance mechanism to convert an unacceptable ASP.NET web control into controls that meet the accessible guidelines. Back to top
WAI, WCAG and Section 508
Many steps can be taken to make Web sites with higher accessibility. But what is the steps? How many steps do you need to use to use it? The answers to these issues differ from the object of the inquiry and the accessibility level required to provide. The visibility level required by the Intranet site of "Fortune 500" enterprise may be higher than the intranet site of only 25 employees.
A statement on accessibility in WC3
To help the proposal legalization, WC3 officially established Web Accessibility Initiative (WAI) in 1999. The task group is to increase the availability of the Web site for disabled people. The first measure of WAI is to publish Web Content Accessibility Guidelines, ie WCAG. WCAG provides 14 guidelines for accessible Web site design.
These guidelines are not detailed in detail which actions need to be taken to make Web sites higher accessibility. They are just some advanced statements, providing advice on how to ensure accessibility. For example, guidelines 1 is "an equivalent alternative option for auditory and visual content." Along with each criterion is a set of checkpoints. These checkpoints detail the actions that can be taken to ensure accessibility criteria. Each checkpoint is given one of the following priority:
? Priority 1 - Web developers must meet this checkpoint, otherwise there will be one or more user groups that cannot access the relevant content. ? Priority 2 - web developers should meet this checkpoint, otherwise there will be one or more user groups feel difficult to access the relevant content. ? Priority 3 - web developers can meet this checkpoint, otherwise there will be one or more user groups encountered difficulties in accessing related content.
In addition to listing these 14 guidelines and their associations, WCAG provides a three-level classification standard for Web site accessibility. The site that implements all priority 1 checkpoints is rated as a level A level compliance. Sites that achieve all priority 1 and priority 2 checkpoints were rated as two A level, and those sites that realized all checkpoints were rated as three A. WCAG provides an appropriate operation to ensure various accessibility levels.
Although a comprehensive discussion of WCAG is not within the scope of this article, this article is still listed below 14 advanced guidelines for WCAG. You can find the checkpoints of each criterion and its associated priority in the official Web Content Accessibility Guidelines 1.0 specification.
1. Equivalent replacement options for auditory and visual content 2. Do not simply depend on color 3. Use tags and style sheets and ensure proper use 4. When using natural language, you should express clear 5. Create a table that can properly convert 6. Make sure The new technology can be properly converted 7. Make sure that the user can control the time-sensitive content change 8. Make sure the direct accessibility of the embedded user interface 9. Design for the independence of the equipment 10. Using a temporary solution 11. Using W3C Techniques and guidelines 12. Provide context and direction information 13. Provide unimpeded navigation mechanisms 14. Make sure documents understand
Visibility guidelines for US government
In 1998, the US government amended the Rehabilitation Act to enable accessibility rules for the federal government maintained by the electronic and online content. These rules are often referred to as the "Section 508 Rules" because the accessibility requirements are explained in detail by Section 508 of the Rehabilitation Act.
Note The full text of Section 508 and the common problem solutions, message boards and training information can be found on www.section508.gov through online way. Other Section 508 information is located on http://www.access-board.gov/508.htm. The federal government has 16 Web site accessibility rules. The first 11 is the checkpoint in WCAG; the last 5 is unique to Section 508, which is not WCAG. These rules are located in the section 508 of 1194.22, this article is described here again here:
1. Equivalent text should be provided for each non-text element 2. Any equivalent alternative to any multimedia display should be synchronized with the original display. 3. Design of the web page should allow all information conveyed by color or not to be obtained by colors, such as from context or tags. 4. The organization of the document should be read without the need to be associated. 5. Redundant text links should be provided for each activity area mapped by the server-side image map. 6. The client image mapping should be provided instead of server-side image mapping, unless the relevant area cannot be defined by the available geometry. 7. The line header and the column header should be identified for the data sheet. 8. For data tables containing two or more logical levels and column headers, you should use the tag to associate data cells and header cells. 9. The text should be used to add a title to the frame to facilitate frame identification and navigation. 10. The design of the page should avoid flashing the screen with a frequency higher than 2 Hz and below 55 Hz. 11. If the Web site is not allowed to make the Web site in accordance with the provisions of this section, a plain text page with equivalent information or feature should be provided to make it compliant. Whenever the original page changes, the contents of the plain text page should be updated. 12. When the page uses a scripting language to display the content or create an interface element, you should use the information available to the script to be used by auxiliary technology. 13. When the web page requires the applet, plug-ins, or other applications to explain the page content, this page must provide links to the corresponding plug-in or applets. 14. When the electronic form is designed to be completed online, the form should allow users of the auxiliary technology to access the information, field elements, and functions required to complete and submit a form, including all descriptions and prompts. 15. A method that allows users to skip repetitive navigation links should be provided. 16. When you need to respond in a timely manner, you should notify the user and provide enough time for users to indicate more time.
The above 16 rules are developed by the US government and only require the federal organization's intranet and Internet Web sites. However, not only the United States requires the Web site of its government agencies to comply with accessibility guidelines. There are similar laws like Australia, Canada, France, Germany, Japan and the United Kingdom. For a list of accessibility policies for each country, please visit WAI's Policies Relating to Web Accessibility page.
Check accessibility compliance
By using free Bobby Online Portal, you can quickly determine if a given web page is in line with WCAG or Section 508. In this Web site, you can enter a URL of a web page, select and check the compliance with the WCAG or Section 508, and then view the report to which it meets the level. Figure 1 shows a screen snapshot of Bobby Online Portal, and the content is the WCAG compliance test that is about to be performed on the Microsoft MSDN home page.
Figure 1.Bobby Online Portal
Figure 2 shows the screen snapshot of the MSDN homepage report. As you can see, the MSDN page does not meet any level of WCAG accessibility criteria because it lacks an alternative text of the image. Although there is no display in Figure 2, there is still five violations of priority 2 checkpoints, and there are four in violation of priority 3 checkpoints.
Figure 2. Accessibility of the Evaluation MSDN Bobby Online Portal is a quite good tool that can be used to determine if your Web site meets WCAG or Section 508 accessibility guidelines. Unfortunately, Bobby Online Portal can only handle one URL at a time, and only one query is permitted per minute. However, commercial products can be used to test accessibility compliance with the entire Web site and will not be subject to a number of queries per minute. For more information on these commercial products, please visit the Bobby Online Portal site.
Back to top
Microsoft can access ASP.NET web control for ASP.NET 1.x
Many WCAG checkpoints and Section 508 rules require specific HTML tags to make Web sites higher accessibility. For example, checkpoints in WCAG 5.1 (which are priority 1 checkpoints) and rule (g) in Section 508 require the
element must be used to identify the data cell, and the header must be identified using | .
When building an ASP.NET Web site, developers rarely need to care about how to generate HTML tags. Developers can use a web control to generate the correct tag. Unfortunately, many ASP.NET Web controls generated by marks violate the accessibility rules described in WCAG and Section 508. Because all web controls are essentially classes in the Microsoft® .NET framework, you can extend their functions in a variety of ways to meet accessibility guidelines. The DataGrid Web control is a typical example of an existing ASP.NET Web control to meet accessibility criteria. The DataGrid web control that comes with the .NET frame does not comply with the checkpoint 5.1 in the rule (g) / WCAG in Section 508. That is, the header is presented using an element instead of an element. (To understand what I mean, please refer to this live playback demonstration, then select "View" and "Source" in the browser. You will see the header line is used instead of.) However, in 2003 6 Month, Microsoft released ASP.NET HotFix Rollup Package. In the content included in the package, there is an improved version of the DataGrid, which complies with rules (g) in Section 508. Note ASP.NET HotFix Rollup package provides additional enhancements related to accessibility. For example, it adds an optional AssociatedControlID property to the Label Web control to specify the ID of the web control associated with the Label. If this property is provided, the Label will be presented as the Back to top Create an adaptive access to DataGrid web control The WEB control provided in the hot repair program in June 2003 upgraded the ASP.NET Web control to the section 508 standard. However, even if the hot repair program is used, there are still many cases that do not comply with WCAG priority 1 checkpoints. Fortunately, you can easily extend the functionality of the existing web control to meet your company's requirements for accessibility guidelines. This is due to the power of inheritance. Specifically, we can extend the Web controls that do not meet the accessibility standards and create a web control that meets these standards. By inheritance, we only need to change or add functions that enable the control to comply with these standards without rewriting basic functions. WCAG checkpoint 6.3 is: "Make sure that the page is still available when the script, applet, or other programming object is turned off or not supported. If this is not available, please provide equivalent information on an alternative access page. For example, make sure that the linked link of the trigger script is still valid when the script is turned off or not supported (for example, "JavaScript:" as a link target). "However, the LinkButton Web control is presented as a JavaScript: link target ( ... ) hyperlinks. The problem is that the browser that does not support JavaScript cannot be returned to the web page by clicking LinkButton. This makes sorted DataGrid becoming inevitable in browsers that do not support JavaScript, because the column headers are presented as LinkButton. The rest of this article explore how to generate a set of adaptive custom DataGrid columns, which will display a Button web control in their headers when the canable DataGrid is not supported by JavaScript browser access. The Button web control is valid for browsers that do not support JavaScript because it presents tag instead of javascript: link target. Note The section 508 does not require a link to use JavaScript: link target. Section 508 The only description of the client script is located in the rule (L), and its content is: "When the page uses a scripting language to display the content or create an interface element, you should use the utility of the auxiliary technology to identify the script. Information. "The requirements for this rule are: If the content is generated by script, or the behavior of the page is modified by script, the Make DataGridColumn adaptive The DataGrid Web control consists of multiple columns, which are classs derived from the System.Web.ui.WebControls.DataGridColumn class. ASP.NET attached to five built-in DataGrid column types: 1. BOUNDCOLUMN 2. ButtonColumn 3. EditcommandColumn 4. HyperLinkColumn 5. TemplateColumn Base class DataGridColumn provides properties and methods inherent in all DataGrid column types. This includes Headertext, Sortexpression, Visible, and other properties. The DataGridColumn class has two ways to play an important role in creating DataGrid: Initialize () - Initializing DataGridColumn. In the data binding process of DataGrid, you call each column once. ? Initializecell (Cell, ITEX, ITEMTYPE) - During the data binding process of the DataGrid, each cell of each column created is called. Cell is a Tablecell object indicating the actual HTML cell of the initialization cell; Index is a row index of the initialization cell; ITEMTYPE is a value in the ListItemType enumeration, which is used to specify the type of cell to be added (Item, AlternatingItem) , HEADER, FOOTER, EDITITEM, etc.). The DataGridColumn class is responsible for rendering the header and footnote of the column. Derive class BoundColumn, ButtonColumn, EditCommandColumn, etc. are responsible for presenting the DataGrid item. Note For more information on creating a custom DataGrid column, see the article Creating Custom Column for the ASP.NET DATAGRID in Marcie Robillard. To make our DataGrid can create a custom DataGrid class from DataGridColumn based on whether JavaScript comes from adaptive presentation headers based on user browsers. This custom DataGrid column class is an AccessibleDataGridColumn, which requires rewriting the DataGridColumn class's initializecell () method, check if the DataGrid is configured to be sorted and is accessed by browser that does not support JavaScript. If the above two conditions are established, AccessibleDataGridColumn will present a Button in the header instead of LinkButton. The code of this class is as follows: Public Class AccessibleDataGridColumn Inherits DataGridColumn Public Overrides Sub InitializeCell (_ ByVal cell As TableCell, _ ByVal columnIndex As Integer, _ ByVal itemType As ListItemType) Dim sorting As Boolean = _ Not Me.Owner Is Nothing _ AndAlso Me.Owner.AllowSorting _ AndAlso Me .SortExpression.Length> 0 Dim supportsJS As Boolean = _ Not HttpContext.Current Is Nothing _ AndAlso HttpContext.Current.Request.Browser.JavaScript If sorting And Not supportsJS _ And itemType = ListItemType.Header And Not Me.DesignMode _ Then If Me .HeaderImageUrl.Length> 0 Then Dim b As New ImageButton b.AlternateText = Me.HeaderText b.ImageUrl = Me.HeaderImageUrl b.CommandName = "Sort" b.CommandArgument = Me.SortExpression b.CausesValidation = False cell.Controls.Add (b) Else Dim b As New Button b.Text = Me.HeaderText b.CommandName = "Sort" b.CommandArgument = Me.SortExpression b.CausesValidation = False cell.Controls.Add (b) End If Else MyBase.InitializeCell ( Cell, ColumnIndex, ItemType) End if End Sub End class rewriting The initializecell () method will check if you are sorted, whether the current browser does not support client JavaScript, is currently initializing whether the item is a header, and whether the presentation does not be in Microsoft? Visual Studio? Net The designer is executed. If you pass, another check is performed to determine if the column specifies the headerimageurl value. If this value is specified, it will present an ImageButton and set its alternateText to the Headertext of the column. If HeaderImageURL is not specified, a Button is created and added to the cell. Note Please note that when checking the browser supports JavaScript, just check the request.browser.javascript property. This property is set to the USER-Agent string of the web server based on the browser. When the user is accessed by a browser that does not support JavaScript (such as Netscape 1.0 or Lynx), the adaptive DataGrid will render Button in the header of the DataGrid. If the user accesses via Microsoft? Internet Explorer 6.0, it will present the default LinkButton, even if the visitor has manually turned off JavaScript support. Create an AccessibleBoundColumn class After creating an AccessibleDataGridColumn class, we need to copy the functionality of the five built-in DataGrid column types (BoundColumn, ButtonColumn, EditCommandColumn et al. To five "accessible" DataGrid column types. This is because the built-in DataGrid column type is sent from DataGridColumn, and the latter does not adaptively rendering Button in the header like AccessibleDataGridColumn. Fortunately, create five new classes and copy five built-in classes are quite simple, and only a small number of code. Let's gradually complete the function of creating a copy of the BoundColumn class but derived from AccessibleDataGridColumn classes. This class is AccessibleBoundColumn, as shown below (for the sake of simplicity, some non-necessarily syntax): Public Class AccessibleBoundColumn Inherits AccessibleDataGridColumn Private bc As New BoundColumn Public Overrides Sub InitializeCell (_ ByVal cell As TableCell, _ ByVal columnIndex As Integer, _ ByVal itemType As ListItemType) 'If this is a header or footer,' initialize the cell ourselves via AccessibleDataGridColumn If itemType = ListItemType.Header _ Or itemType = ListItemType.Footer Then MyBase.InitializeCell (cell, columnIndex, itemType) Else bc.InitializeCell (cell, columnIndex, itemType) End If End Sub #Region "Public Properties" The initializecell () method is also rewritten because we want to render the DataGrid item through internal BoundColumn, and rendering headers (and footnotes) through AccessibleDataGridColumn. Then, the initializecell () method only checks which type of item to initialize, and entrust the initialization responsibilities to the base class (AccessibleDataGridColumn) or the internal BoundColumn. Note The download information related to this article includes the complete source code for AccessibleDataGridColumn and AccessibleBoundColumn and the source code for AccessibleButtonColumn. I will leave the reader by the creation of the rest of the DataGrid column class (these creation work is required to replicate the last three built-in DataGrid columns). Back to top Use accessible DataGrid column class in the ASP.NET web page The download information of this article consists of two Microsoft? Visual Studio? Net 2003 projects (all Visual Basic .NET projects): The first project is a class library that contains custom DataGrid column classes; the second project is an ASP. NET web applications can be used to test adaptive accessible DataGrid column classes. To use these custom DataGrid column classes in the ASP.NET Web project, you need to add a compiled assembly of the custom DataGrid column class to the / bin folder of the ASP.NET Web project. (If you use Visual Studio .NET, the easiest way to complete this task is to add the assembly to the REFERENCES folder of the Solution Explorer.) Next, you need ASP.NET that will take advantage of these DataGrid Add a @References instruction at the top of the web page, as shown below: <% @ Register tagprefix = "accessibility" namespace = "accessibilityControls" assembly = "accessibilityControls"%>%> Finally, use these columns, add a DataGrid to the ASP.NET web page and set the AutoGenerateColumns property to false. In the HTML section, add the following speech: This is all steps! Figure 3 shows a screen snapshot of the HTML section of the ACCESSIBLEBOUNDCOLUMN and the ACCESSIBLEBUTTONCOLUMNDATAGRID column class. Figure 4 shows the screen snapshot of the design view of the same page. Figure 3. Using AccessibleBoundColumn Figure 4. AccessibleboundColumn in the designer Note that in the Visual Studio .NET designer, DataGrid with custom accessible columns has a normal appearance. Also, if you view this page by supporting JavaScript (as shown in Figure 5), the DataGrid will be rendered in a normal manner and a linkbutton is present in the column header and ButtonColumn. However, if you view this page via a browser (such as Netscape 1.0) that does not support JavaScript, the ButtonColumn and the column header will be presented as Button (see Figure 6). Figure 5. AccessibleboundColumn in advanced browsers Figure 6. AccessibleboundColumn in the old browser Back to top Accessibility in ASP.NET WHIDBEY The ASP.NET server control released in the next version of the ASP.NET (Cycrapership WHIDBEY) will automatically generate a markup 508 by default. Moreover, these server controls will also generate tags that match WCAG. As a final solution, Microsoft? Visual Studio? .NET 2005 will come with an add-in to automatically check if the HTML tag is compliant with Section 508 and WCAG. For more information on these exciting additional features, see XHTML and Accessibility In Asp.Net Whidbey, this is a network diary of the joint founder Scott Guthrie of Microsoft's ASP.NET Working Group. For more information on web site accessibility, see Microsoft Accessibility Homepage. You can also refer to the section 508, which contains resources about how the various Microsoft products meet the Section 508 standard. Source: http://www.microsoft.com/msdn/library/webservices/asp.net/makinganaspnetWebsiteAccessible.mspx
转载请注明原文地址:https://www.9cbs.com/read-21183.html New Post(0)
|
---|