Export (0) Print
Expand All

WebControl.AccessKey Property

Gets or sets the access key that allows you to quickly navigate to the Web server control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

abstract AccessKey : string with get, set 
override AccessKey : string with get, set

Property Value

Type: System.String
The access key for quick navigation to the Web server control. The default value is Empty, which indicates that this property is not set.

ExceptionCondition
ArgumentOutOfRangeException

The specified access key is neither a null reference (Nothing in Visual Basic), Empty nor a single character string.

Use the AccessKey property to specify the keyboard shortcut for the Web server control. This allows you to navigate quickly to the control by pressing the ALT key and the key for the specified character on the keyboard. For example, setting the access key of a control to the string "D" indicates that the user can navigate to the control by pressing ALT+D.

Only a single character string is allowed for the AccessKey property. If you attempt to set this property to a value that is neither a null reference (Nothing in Visual Basic), Empty, nor a single character string, an exception is thrown.

NoteNote

This property is supported only in Internet Explorer 4.0 and later.

TopicLocation
How to: Add Button Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add Button Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Check Accessibility of Web Pages in Visual Web DeveloperBuilding ASP .NET Web Applications in Visual Studio
How to: Add Button Web Server Controls to a Web Forms Page (Visual Studio)Building ASP .NET Web Applications in Visual Studio

The following example illustrates how to set and use the AccessKey property of a TextBox control.

Security noteSecurity Note

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft