Easy access to the ASP.NET Web site

xiaoxiao2021-03-06  27

Release Date: 09/03/2004

| Update Date: 09/03/2004

Scott mitchell4guysfromrolla.commicrosoft corporation

Suitable for: Microsoft ASP.NET 1.1MICROSoft ASP.NET 2.0MICROSOFT VISUAL Studio .NET

Summary: Use the inheritance of the .NET Framework to extend the ASP.NET class to generate the ASP.NET code that the disabled person is fully accessible.

Click here to download the code example of this article.

This page

Introduction WAI, WCAG, and Section 508 Microsoft for ASP.NET 1.x Easy access ASP.NET Web control creates an adaptive, easy access to DataGrid web controls using easy-to-access DataGrid columns in the ASP.NET web page Accessibility related books in class ASP.NET 2.0

Introduction

Although most online users can use a web browser with typical browser settings to browse the Web site, but if there is a disability user usually uses other methods to access online information. For example, a blind user may use a plain text browser that converts text into Braille, or uses a screen reader to read text. A person with visual obstacles may still use a browser such as Internet Explorer, but to make a browser configured to use a large font size by means of a screen magnifying glass or by means of a browser configured to use a large font size. Action barriers may hinder the user's mouse or keyboard as an input device.

Because people with disabilities typically browse the Web using special devices or non-standard browser configurations, the overall design of a Web site and HTML tags greatly affect the user experience of persons with disabilities. For example, the font size is specified with an absolute measure unit (such as 10pt), and the font size is displayed in the absolute size and is independent of the size of the text configured in its browser. There are flash or shockwave interfaces and do not provide alternative sites in the form of a form, in fact, rejected users who use Braille devices or text speech synthesizers. One Web site is only designed to be able to convert to an alternative device, can be said to be easy to access.

At this point, you may think: "Why do I have to ensure that my web site is easy to access?" I want to have two main reasons:

1. This is a good business - according to the 2000 US census, 49.7 million Americans have disabilities; Harris Interactive Survey in June 2000 shows 43% of the United States disabled people are often online users, and disabled users Internet access The time spent is almost twice as the non-disabled user. To put the results of these two surveys, you will find that more than $ 21 million of American disabled people are often online. If you don't take time to make your Web site easy access, you will reject 21 million potential visits. 2. This is a government agency's directive - in 1998, the US government adopted the section 508 of The Rehabilitation Act, requiring the electronic information of the federal agency to be accessible for persons with disabilities. This bill provides accessibility guidelines for software applications, web applications, and telecommunications products and video products. Not only requires federal agencies to implement accessibility guidelines, but also requests to sign a contract for private companies working by the federal government. (Many countries outside the United States also have similar accessibility requirements for government agencies.) So, if you work for the government or to provide services to the government, create an easy-to-access web application is required.

In this article, we will discuss which steps can be taken to make sure your ASP.NET Web site is easy access. We will briefly look at the official accessible guidelines currently available, and then look at the accessible guidelines used by the US government. This article focuses on how to use inheritance ASP.NET web controls that will not be easy to access to meet accessible guidelines. Back to top

WAI, WCAG and Section 508

Many steps have been easier to access a Web site, but what is these steps? How many steps need to be used in a site can be seen as an easy access? These issues will vary depending on the object you ask and the accessibility level they need. For an intranet site of a Fortune 500 (Fortune 500), it is likely to have a higher level of accessibility than an intranet site with only 25 employees.

WC3 about accessibility

To help this discussion, 1999 WC3 officially established Web Accessibility Initiative (WAI), which is assigned a group that enhances Web site availability for disabled people. WAI's first action is to release Web Content Accessibility Guidelines (WCAG). WCAG provides a list of 14 guidelines to design a Web site that is easy to access.

The guidelines are not detailed in detail to make a Web site more easily access to the operations that should be taken. Specifically, they are high-level declarations for how to ensure accessibility. For example, criteria 1 is "an alternative to the auditory and visual content." Each criterion comes with a set of checkpoints. The checkpoint details the operations 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 one or more user groups will not access this content. • Priority 2 - Web developers should meet this checkpoint, otherwise one or more user groups will find difficult to access this content. • Priority 3 - web developers can meet this checkpoint, otherwise one or more user groups may have difficulty accessing this content.

In addition to listing the 14 guidelines and their associated, setting priority checkpoints, WCAG also provides a three-level classification level for the accessibility of the Web site. Realizing all priority 1 checkpoints is assessing as meeting A. Realizing all the priority 1 and priority 2 checkpoints are assessing as dual A, while the site that implements all checkpoints is measured as three A level. WCAG provides a good set of operations to perform, which ensures different accessibility levels.

The detailed discussion of WCAG exceeds the scope of this article. The following is the 14 high-level criteria for WCAG. The checkpoints of each criterion and their associated priorities can be found in the official Web Content Accessibility Guidelines 1.0 Specification.

1. Provide an equivalent alternative to the auditory and visual content. 2. Do not rely on color. 3. Use the tags and style sheets for proper use. 4. Explain the use of natural languages. 5. Create a form of normal conversion. 6. Make sure that the page conversion is normal in the page characteristic. 7. Make sure the user controls the time-sensitive content change. 8. Make sure the direct accessibility of the embedded user interface. 9. Designed with equipment. 10. Use a transition solution. 11. Use W3C technology and guidelines. 12. Provide context and directional information. 13. Provide a simple navigation mechanism. 14. Make sure the documentation is clear.

Visibility guidelines for US government

In 1998, the US government revised the Rehabilitation ACT to develop accessibility rules for electronics and online content maintained by the federal government. These rules are often referred to as "Section 508 Rules", which is the section 508 of the rehabilitation bill for accessibility requirements.

Note The full text of section 508 and FAQ, message boards, and training information can be found online on www.section508.gov. Other information about Section 508 can be obtained on www.access-board.gov/508.htm. For Web site accessibility, the federal government has 16 rules. The first 11 is a checkpoint from the WCAG, and the last 5 is for section 508, not the component of WCAG. These rules can be found in the Section 508 1194.22, for the full description, repeat it here:

1. A equivalent text should be provided for each non-text element. 2. Equivalent alternatives of any multimedia presentation should be synchronized with the presentation. 3. The web page should be designed so that all information conveyed by color does not require color, such as obtaining by context or tag. 4. Documents should be organized so that they can be read without the need to associate style table. 5. There should be redundant text links for each activity area mapped to the server-side image map. 6. The client image map should be provided instead of server-side image mapping, unless the area cannot be defined using the available geometry. 7. The row and column headings should be identified for data sheets. 8. For data tables with two or more logical hierarchies, you should use the data cells and title cells that are marked as these data labels. 9. The text that helps frame identification and navigation should be used to add titles to the frame. 10. The page should be designed to avoid flashing in the case where the frequency is greater than 2 Hz and less than 55 Hz. 11. When compliance with any other method, a plain text page with equivalent information or function should be provided to make the Web site in accordance with the provisions of this part. As long as the main page changes, the content 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, the information provided by the script should be consistent with the functional text that the auxiliary technology can read. 13. When the web page requires a small program, plugin, or other application on the client system to explain the page content, this page must provide a link to a plugin or applet. 14. When the electronic form is designed to complete online, the form should allow the user to access the information, field elements and functions required to complete and submit a form, including all the instructions and prompts. 15. A method should be provided allows the user to skip the repeated navigation link. 16. When a timing response is required, the user should be warned and given a sufficient time to indicate more time.

These 16 rules are well-developed by the US government and only ordered the Intranet and Internet Web site of the federal organization. However, in order to perform accessibility guidelines in ordering government agencies, the United States is not unique. There are also similar laws in Australia, Canada, France, Germany, Japan and the United Kingdom. For a list of visibility policies listed in the country, please visit WAI's Policies Relating to Web Accessibility page.

Check if it meets accessibility

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 Check, or comply with the WCAG or comply with Section 508, and then view reports listing compliance levels. Figure 1 shows a screenshot of Bobby Online Portal, showing a WCAG compliance test that will be executed on the Microsoft MSDN home page.

Figure 1. Bobby online portal

Figure 2 shows a screenshot of the MSDN homepage report. As you can see, the MSDN page does not meet any level of the WCAG accessibility criteria because it lost the alternative text of the image. As shown in Figure 2, there are five conflicts of 5 priority 2 and 4 priority 3 conflicts. Figure 2. Accessibility of evaluating MSDN pages

For the visibility guidelines that determine if your Web site meets WCAG or Section 508, Bobby is a good tool. Unfortunately, Bobby can only handle one URL each time, only one query is permitted every minute. However, there is a commercial product available to test whether the entire Web site meets accessibility and does not limit only a certain number of queries per minute. More information about these commercial products can be found on the Bobby online portal site.

Back to top

Microsoft easy access to ASP.NET 1.x is easy to access ASP.NET web control

Many WCAG Checkpoints and Section 508 Rules stipulate that the specified HTML tag should make Web sites easier access. For example, checkpoints in WCAG 5.1 (a priority 1 checkpoint) and rule (7) in Section 508 require

element to correctly identify rows and column headings. That is, the element identification data cell must be used, but the identity header must be used.

When building an ASP.NET Web site, developers are hardly worried about generating HTML tags. Instead, use the WEB control that issues a correct mark. Unfortunately, many ASP.NET web controls conflicts with accessibility rules specified by WCAG and Section 508. Since all WEB controls appear in a class of .NET Framework, their functions can be extended to meet accessibility guidelines through a variety of ways.

The DataGrid Web Control is to enhance an existing ASP.NET Web control to meet the accessibility criteria. The DataGrid Web control included with the .NET Framework does not comply with the rules (7) in Section 508 and checkpoints 5.1 in WCAG. That is to say, use an element instead of presenting a title. (To understand what I said, please check the live demo and view "Source" under "View" in the browser. You will see the title line to use

and not.) However, in 2003 6 Month, Microsoft released ASP.NET HotFix Rollup Package, compared to other packages, which included a DataGRID that complies with Rule (7) 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, Label will be rendered as the

Back to top

Create an adaptive, easy access to DataGrid web control

The web control provided in the hot repair program released in June 2003, promoting the ASP.NET Web control to the standard of Section 508. However, even if there is a hot repair program, there is still a checkpoint of many WCAG priority 1. Fortunately, you can easily extend the functionality of the existing web control to meet your company's request for accessibility guidelines. This may be due to the role of inheritance. In particular, we can use web controls that do not meet accessibility standards and create a standard extension web control. By using inheritance, we only need to change or add functions to comply with standards without having to rewrite basic functions. Wring in WCAG Checkpoint 6.3: "Make sure the page can still be used when the script, applet, or other programming object is turned off or not supported. If you can't do this, you can provide equivalent on an alternative accessible page. Information. For example, when the script is turned off or not supported, make sure that the linked link is normal (such as: Do not use "JavaScript:" as a link target). "However, the LinkButton Web control is as a JavaScript: link Target ( ... ) hyperlink is presented. The problem is that a browser that does not support JavaScript cannot return to the web page by clicking the LinkButton. In a browser that does not support JavaScript, this makes sorted DataGrid rendered in orderless, because the column header is rendered as a linkbutton

The remainder of this article focus on building a set of adaptive custom DataGrid columns, if you do not support JavaScript, you will display a Button web control in the tabs of the canable DataGrid. Because the Button web control presents tag rather than the JavaScript: The hyperlink of the link target, it can be used to not support JavaScript browsers.

Note The section 508 requires a link to use the JavaScript: link target. The unique comment for the client script in Section 508 can be found in the rule (12), which is written in: "The page uses the scripting language to display the content, or create an interface element, the information provided by the script should be used by secondary technology. The function text is identified. "This rule requires that if the content is generated by script, or if a page is modified by script, you should use a & lt; script> html element with explanation script behavior. In any case, I listen to some developers engaged in government projects, or ask them to support browsers without JavaScript feature.

Make DataGridColumn adaptable

The DataGrid Web control consists of many columns, which are classes derived from the System.Web.ui.WebControls.DataGridColumn class. ASP.NET comes with 5 built-in DataGrid column types:

1. BOUNDCOLUMN 2. ButtonColumn 3. EditcommandColumn 4. HyperLinkColumn 5. TemplateColumn

Base class DataGridColumn provides intrinsic and methods inherent in all DataGrid column types. This includes such as Headertext, sortexpression¡¡. ¢ Visible and other properties. When creating a DataGrid, there are two ways to play an important role in the DataGridColumn class: • Initialize () - Initialization DataGridColumn¡ £ Turn once in the data binding process of DataGrid. • Initializecell (Cell, Index, ItemType) - During the data binding process of DataGrid, for each cell created for each column. Cell is a Tablecell object that represents the actual HTML

cell of the cell being initialized; Index is a row index of the cell being initialized; ITEMTYPE is the value of the ListItemType enumeration, specifies which type of type Cell (Item, AlternatingItem, Header, Footer, EditItem, etc.).

The DataGridColumn class is responsible for rendering the title and footnote of the column. Derivatives such as BoundColumn, ButtonColumn, and EditCommandColumn are responsible for presenting the DataGrid item.

Note For more information on creating custom DataGrid columns, review the article Creating Custom Column for the ASP.NET DATAGRID for Marcie Robillard.

In order to make our DataGrid depending on whether the user's browser supports JavaScript from adaptively rendering the title, we need to create a custom DataGrid class derived from DataGridColumn. This custom DataGrid column named AccessibleDataGridColumn will need to rewrite the DataGridColumn class's initializecell () method to see if the DataGrid is configured to be sorted and can be accessed by browsers that do not support JavaScript. If these two conditions are true, AccessibleDataGridColumn will present Button instead of LinkButton in the title. The code of this class is shown below.

Public Class AccessibleDataGridColumn

Inherits DataGridColumn

Public Overrides Sub Initializecell (Byval Cell As Tablecell, _

Byval ColumnIndex as INTEGER, BYVAL ITEMTYPE AS LISTITITYMTYPE

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.ALTERNATEXT = 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

The rewritten initializecell () method will check to see if the sort is enabled, whether the current browser supports client JavaScript, whether the currently initialized item is the title and whether it is executed in the Visual Studio .NET designer. If this check is passed, another check is executed to determine if the column has a specified headerimage value. If so, it will present an imageButton, set its AlternateText to the column headerText. If you don't specify HeaderImageURL, you will create button and add it to the cell.

CAUTION, check if the browser supports JavaScript, only when the browser supports JavaScript, only looks for the request.browser.javascript property. This property is set according to the user-agent string sent to the web server to the web server. When someone uses a browser (such as Netscape 1.0 or Lynx) that is known to not support JavaScript, adaptive DataGrid will be sorted by DataGrid in the title in the title. £ Visit by Internet Explorer 6.0, even if the visitor has manually turned off JavaScript support, it will also present the default linkbuttons.

Create an AccessibleBoundColumn class

After creating an AccessibleDataGridColumn class, we need to copy 5 built-in DataGrid column types (BoundColumn, ButtonColumn, EditCommandColumn, and other types), as 5 new "easy access" DataGrid column types. We do this because the built-in DataGrid column type is derived from DataGridColumn, and it is unlike our AccessibleDataGridColumn, it is adaptively presented in the title in the title. Fortunately, 5 new classes that create 5 built-in classes are relatively simple, only a small amount of code is required.

Let us gradually by creating a class process, which can copy the function of the BoundColumn class, but derive from AccessibleDataGridColumn. This class called AccessibleBoundColumn is as follows (for simplification, some unimportant syntax has been deleted).

Public Class AccessibleBoundColumn

Inherits AccessibleDataGridColumn

Private BC As New BoundColumn

Public overrides subinitializecell (Byval Cell As Tablecell, _Byval ColumnIndex As INTEGER, BYVAL ITEMTYPE AS LISTITEPE)

'If this is a header or footer, Initialize the Cell Ourslves

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"

_

Public property datafield () AS STRING

Get

Return bc.datafield

END GET

Set (byval value as string)

bc.datafield = value

End set

End Property

_

Public property dataformatstring () AS STRING

Get

Return bc.DataFormatString

END GET

Set (byval value as string)

bc.DataFormatString = Value

End set

End Property

_

Public property [readonly] () as boolean

Get

Return Bc.Readonly

END GET

Set (ByVal Value As Boolean)

bc.readonly = value

End set

End Property

#End region

END CLASS

Copying 5 built-in DataGrid column classes can hardly spend, because you can entrust your labor to a private member instance of the appropriate column type. For example, in the AccessibleBoundColumn class, the BoundColumn type has a private member variable called BC. AccessibleBoundColumn requires at least the same properties as the BoundColumn class, although these properties can be read directly through the same properties in the internal BoundColumn.

The initializecell () method has also been rewritten because we want to render the items of the DataGrid through internal BoundColumn while making the title (and footnotes) rendered through AccessibleDataGridColumn. Then, the initializecell () method is only checked to see which type of item being initialized, and entrust the initialization responsibility to the base class (AccessibleDataGridColumn) or internal BoundColumn.

Note The download associated with this article includes the full source code for AccessibleDataGridColumn and AccessibleBoundColumn, as well as the source code for AccessibleButtonColumn. I left it to the reader as an exercise to create the remaining DataGrid column class, which is required for the three built-in DataGrid columns after replication.

Back to top

Use easy-to-access DataGrid column class in the ASP.NET web page

This article downloads two Visual Studio .NET 2003 items (both are Visual Basic .NET projects): The first is a class library that contains custom DataGrid column classes; the second is an ASP.NET web application You can use it to test the DataGrid column class that can be accessed, easy to access. To use these custom DataGrid columns in the ASP.NET Web project, you need to add a compiled custom DataGrid column class set to the / bin folder of the ASP.NET Web project. (If you are using Visual Studio .NET, the easiest way to do this is to add the assembly to the References folder in the Solution Explorer.) Next, you will need to be on the top of the ASP.NET web page Add a @References instruction, which will use these DataGrid columns as follows.

<% @ Register tagprefix = "accessibility"

Namespace = "AccessibilityControls" asmbly = "accessibilityControls"%>%>

Finally, you want to use columns, add DataGrid to the ASP.NET web page and set the AutoGenerateColumns property to false. In the HTML section, add the following syntax.

...

This is all steps! Figure 3 shows a screenshot of the HTML section of the ASP.NET web page using AccessibleBoundColumn and AccessibleButonColumn clauses. Figure 4 shows a screenshot 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, the DataGrid with custom, easy access is true, as it is the same as ordinary. Moreover, if you view the page (as shown in Figure 5) by supporting JavaScript, DataGrid will be rendered, in column headers and ButtonColumn, which is LinkButtons, but if you do not support JavaScript browser (such as Netscape 1.0) Access page, ButtonColumn and column headings will be rendered as Buttons (see Figure 6).

Figure 5. AccessibleBoundColumn in the superior browser

Figure 6. AccessibleboundColumn in earlier versions of the browser

Back to top

Accessibility in ASP.NET 2.0

The ASP.NET server control published in the next version of ASP.NET (Codenames Whidbey) will automatically generate the marks that comply with Section 508 by default. Moreover, these server controls will also issue tags that conform to WCAG. In order to achieve this goal, Visual Studio 2005 will accompany an add-in to check if the HTML tag is compliant with Section 508 and WCAG. For more information on these exciting new features, please refer to XHTML and Accessibility In Asp.Net Whidbey and a BLOG announcement from Scott Guthrie (joint founders of Microsoft ASP.NET team). For more information on web site accessibility, please refer to Microsoft Accessibility Home: www.microsoft.com/enable/. Also see Section 508 Page for resources about how a variety of Microsoft products meet Section 508 standards.

Back to top

Related books

• Accessibility for Everybody: Understanding The Section 508 Accessibility Requirements • Web Accessibility For People With Disabilities • ASP. Net: Tips, Tutorials, and Code

About author

Scott Mitchell has 5 books and is the founder of 4Guysfromrolla.com, which has been working on Microsoft Web technology in the past six years. SCOTT body and independent consultants, trainers, and writers. You can get in touch with him through mitchell@4guysfromrolla.com or through his blog on Scottonwriting.net.

Go to the original English page

Back to top

转载请注明原文地址:https://www.9cbs.com/read-65394.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.064, SQL: 10