Partilhar via


ASP.NET Controls and Accessibility

ASP.NET enables you to create Web pages that conform to accessibility guidelines. For details, see Accessibility Support in ASP.NET.

To create accessible Web applications in ASP.NET, you must understand how ASP.NET server controls support accessibility. In many cases, you must configure a control to create markup that conforms to accessibility guidelines. In a few cases, ASP.NET server controls cannot be used in applications that must be 100 percent conformant with Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. In those cases, you must avoid using the controls.

ASP.NET Control Guidelines for Accessibility

The following table lists ASP.NET server controls and provides information about accessibility support for the control. If a control is not listed in the table, its output conforms to accessibility guidelines without any configuration requirements.

Control

Accessibility support

AppearanceEditorPart

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

BehaviorEditorPart

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

BulletedList

If the control's DisplayMode property is set to LinkButton, the control requires client script to function. To avoid the need for client script, create templates and add Button controls for these functions.

When the control's BulletStyle property is set to CustomImage, ensure that the graphic does not convey meaning that would not be available to users who cannot view the graphic.

Setting the Target property for links opens a new window, which is not recommended by accessibility guidelines.

Button

Setting the OnClientClick property causes the button to depend on client script.

Calendar

The control does not render a header in columns but does render th elements with a scope for the heading.

The control layout is rendered using an HTML table, which is not recommended by some guidelines. Set the control's Caption and CaptionAlign properties to render a caption for the table, as recommended in accessibility guidelines.

The control renders LinkButton controls for navigation, which require client script to function. To avoid the need for client script, create templates and add Button controls for these functions.

CatalogZone

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

ChangePassword

The control requires client script to function.

If you configure the control to use images, set the corresponding text property to the appropriate alternate text. For example, if you set the ChangePasswordButtonType property to Image, set the ChangePasswordButtonText property to alternate text.

CheckBox

Setting the AutoPostBack property to true causes the control to require client script.

CheckBoxList

Setting the AutoPostBack property to true causes the control to require client script.

CreateUserWizard

If you configure the control to use images, set the corresponding text property to appropriate alternate text. For example, if you set the CancelButtonType property to Image, set the CancelButtonText property to alternate text.

Buttons in the control, such as the Submit button and links to move between steps, require client script.

DataPager

If the QueryStringField property is not set and you are using NumericPagerField or NextPreviousPagerField objects, the DataPager control requires client script. If the pager-field objects are configured to use images, you cannot explicitly specify alternate text for the images. The images use the text properties (such as NextPageText) as the alternate text. As an alternative, use the TemplatePagerField object so that you can define exactly what the pager displays.

DetailsView

If you create a ButtonField column and specify an image for the button, you cannot explicitly specify alternate text for the image. The image uses the object's Text property as the alternate text.

The control layout is rendered using an HTML table, which is not recommended by some guidelines because it does not include table header information.

If you enable paging and you set the NextPageImageUrl and PreviousPageImageUrl properties, you cannot explicitly set the alternate text for the images used as paging buttons. Instead, use the PagerTemplate property so that you can define exactly what the pager displays.

By default, this control uses LinkButton controls, which require client script for functions such as switching to edit mode, paging, and so on. To avoid the need for client script, create templates and add Button controls for these functions.

Text boxes generated automatically when you set the control's AutoGenerateEditButton property to true have no associated label elements. To avoid this, create template fields and add your own Label and TextBox controls, and associate them manually. Set the control's Caption and CaptionAlign properties to render a caption for the table, as recommended in accessibility guidelines.

DropDownList

The control does not support the recommended ListItemGroup to allow the list to be subdivided into sections.

Setting the AutoPostBack property to true causes the control to require client script.

EditorZone

All verbs display the same alternate text when icons are displayed.

The control requires client script to function.

The control does not render access key or tab index settings.

The control does not generate label elements to associate labels with controls.

Alternate text for links is rendered but is not customizable.

FormView

The control layout is rendered using an HTML table, which is not recommended by some guidelines because it does not include table header information.

By default, the control uses LinkButton controls, which require client script, for functions, such as switching to edit mode, paging, and so on. To avoid the need for client script, use the PagerTemplate property and add Button controls for these functions.

Set the control's Caption and CaptionAlign properties to render a caption for the table, as recommended in accessibility guidelines.

GridView

Set the RowHeaderColumn property to the name of a data field and the UseAccessibleHeader property to true to have the control render table header information that meets accessibility guidelines.

If you create a ButtonField object and specify an image for the button, you cannot explicitly specify alternate text for the image. The image uses the object's Text property as the alternate text.

Set the control's Caption and CaptionAlign properties to render a caption for the table, as recommended in accessibility guidelines.

By default, the control uses LinkButton controls, which require client script, for functions, such as switching to edit mode, paging, and so on. To avoid the need for client script, create templates and add Button controls for these functions.

If you enable paging and set the NextPageImageUrl and PreviousPageImageUrl properties, you cannot explicitly set the alternate text for the images used as paging buttons. Instead, use the PagerTemplate property so that you can define exactly what the pager displays.

The default controls used to implement editing, selecting, paging, and other update functions require client script. To avoid this, create template columns and add Button controls manually.

Text boxes generated automatically when you set the control's AutoGenerateEditButton property to true have no associated label elements. To avoid this, create template columns and add your own Label and TextBox controls, and associate them manually.

If you enable sorting, the links in the column headers are LinkButton controls and require client script to function. To avoid the need for client script, create templates and add Button controls for these functions.

HyperLink

If you set the ImageUrl property to the URL of a graphic file, set the Text property to specify the alternate text for the resulting graphic.

Setting the Target property for links opens a new window, which is not recommended by accessibility guidelines.

Image

By default, the control renders no alternate text. Set the AlternateText property. If the graphic has no functional purpose, set the GenerateEmptyAlternateText property to true to render an alt set to an empty string (""), which causes screen readers to skip the graphic.

ImageButton

The control requires client script to function.

By default, the control renders no alternate text. Set the AlternateText property.

Do not use the ImageButton control as an image map, because it does not support regions with their own alternate text. Use the ImageMap control instead.

ImageMap

By default, the control renders no alternate text. Set the AlternateText property.

If you set the HotSpotMode property of the control or of individual hot spots to PostBack, the control requires client script to function.

Setting the Target property for links opens a new window, which is not recommended by accessibility guidelines.

Label

To use the control to render a label for a text box or other control, set the AssociatedControlID property to the ID of the control to associate with the label.

LayoutEditorPart

Always include the LayoutEditorPart control with other Web Parts controls to make a page accessible. Otherwise, users can only use a mouse to drag Web Parts controls.

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

LinkButton

The control requires client script to function.

Do not set the Text property of multiple LinkButton controls to the same string, because users relying on screen readers will not be able to distinguish the buttons.

ListBox

The control does not support the recommended ListItemGroup to allow the list to be subdivided into sections.

Setting the AutoPostBack property to true causes the control to require client script.

Login

When the LoginButtonType property is set to Image, the value of the LoginButtonText property is used as the alternate text.

The control does not render access key or tab index settings.

LoginName

Set the ToolTip property to text such as Logged in as username so that screen readers will interpret the control's text correctly.

LoginStatus

The control uses a LinkButton control to display the Logout link, and therefore requires client script to function. To avoid the need for client script, create templates and add Button controls for these functions.

Menu

Set the control's SkipLinkText property to a string to have the control render the recommended skip navigation link.

The control requires client script to function.

In browsers that do not support the full client-side functionality of the control, the browser will refresh the window to show the secondary navigation, which might cause screen readers to begin reading the page again.

Setting the Target property for links opens a new window, which is not recommended by accessibility guidelines.

The control layout is rendered using an HTML table, which is not recommended by some guidelines.

Configuring the control to have mouse pointer side effects (such as creating shortcut menus) is not recommended by accessibility guidelines.

PageCatalogPart

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

PasswordRecovery

If the page's ClientTarget property is set to Downlevel, the control requires client script to function.

When the SubmitButtonType property is set to Image, the value of the SubmitButtonText property is used as the alternate text.

The control does not render access key or tab index settings.

PropertyGridEditorPart

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

RadioButton

Setting the AutoPostBack property to true causes the control to require client script.

RadioButtonList

Setting the AutoPostBack property to true causes the control to require client script.

SiteMapPath

Set the control's SkipLinkText property to a string to have the control render the recommended skip navigation link.

In the site map XML file, set the description attribute of each site-map node to provide a title that screen readers can use to identify navigation links.

Table, TableRow, TableCell, TableHeaderCell, TableHeaderRow, and TableFooterRow

Set the control's Caption and CaptionAlign properties to render a caption for the table, as recommended in accessibility guidelines.

When creating a Table object, include the TableHeaderRow and TableHeaderCell controls.

In the TableHeaderRow, Table, and TableFooterRow controls, set the TableSection property to TableBody, TableHeader, or TableFooter. This causes the control to render thead, tbody, and tfoot elements, respectively.

In TableCell controls, set the AssociatedHeaderCellID property to have the control render a header that associates the cell with its heading.

Set the control's Scope property to associate the header with the corresponding data column.

TextBox

Setting the AutoPostBack property to true causes the control to require client script.

TreeView

Set the control's SkipLinkText property to a string to have the control render the recommended skip navigation link.

Setting a node's PopulateOnDemand property to true causes the control to behave in a way that is not compatible with accessibility guidelines.

The control requires client script to function.

Setting the Target property to _blank for the TreeView control or for individual nodes causes the control to open a new window, which is not recommended by accessibility guidelines.

WebPartZone

The control does not generate label elements to associate labels with controls.

All verbs generate the same link text.

Alternate text for links is rendered but is not customizable.

The control requires client script to function.

The control does not render access key or tab index settings.

If you set the HelpMode property to Modal or Modeless, the control opens a new window, which is not recommended by accessibility guidelines.

Wizard

The control renders LinkButton controls for navigation, which require client script to function. To avoid the need for client script, create templates and add Button controls for these functions.

Validator controls

By default, validation controls render client script to perform client-side validation. However, because built-in validator controls (except the CustomValidator control) automatically perform a redundant validation check in server code, you can set the EnableClientScript property to false to avoid rendering client script for the validation controls.

Set the Text and ErrorMessage properties to meaningful error messages. Do not set them to an asterisk (*).

See Also

Concepts

Accessibility Support in ASP.NET