WebControl.AccessKey Property
Assembly: System.Web (in system.web.dll)
/** @property */ public String get_AccessKey () /** @property */ public void set_AccessKey (String value)
public function get AccessKey () : String public function set AccessKey (value : String)
Property Value
The access key for quick navigation to the Web server control. The default value is Empty, which indicates that this property is not set.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.
Note |
|---|
| This property is supported only in Internet Explorer 4.0 and later. |
| Topic | Location |
|---|---|
| How to: Add Button Web Server Controls to a Web Forms Page | Building ASP .NET Web Applications |
| How to: Add Button Web Server Controls to a Web Forms Page | Building ASP .NET Web Applications |
| How to: Check Accessibility of Web Pages in Visual Web Developer | Building 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.
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> </head> <body> <h3>AccessKey Property of a Web Control</h3> <form runat="server"> <asp:TextBox id="TextBox1" AccessKey="Y" Text="Press Alt-Y to get focus here" Columns="45" runat="server"/> <p> <asp:TextBox id="TextBox2" AccessKey="Z" Text="Press Alt-Z to get focus here" Columns="45" runat="server"/> </form> </body> </html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Note