Gets or sets the access key that allows you to quickly navigate to the Web server control.
Assembly: System.Web (in System.Web.dll)
Public Overridable Property AccessKey As [%$TOPIC/t4274287_en-us_VS_110_1_0_0_0_0%]
public virtual [%$TOPIC/t4274287_en-us_VS_110_1_0_1_0_0%] AccessKey { get; set; }
public:
virtual property [%$TOPIC/t4274287_en-us_VS_110_1_0_2_0_0%]^ AccessKey {
[%$TOPIC/t4274287_en-us_VS_110_1_0_2_0_1%]^ get ();
void set ([%$TOPIC/t4274287_en-us_VS_110_1_0_2_0_2%]^ value);
}
abstract AccessKey : [%$TOPIC/t4274287_en-us_VS_110_1_0_3_0_0%] with get, set
override AccessKey : [%$TOPIC/t4274287_en-us_VS_110_1_0_3_0_1%] with get, set
<asp:[%$TOPIC/t4274287_en-us_VS_110_1_0_4_0_0%] AccessKey="[%$TOPIC/t4274287_en-us_VS_110_1_0_4_0_1%]" />
Property Value
Type: SystemStringThe access key for quick navigation to the Web server control. The default value is Empty, which indicates that this property is not set.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The specified access key is neither , 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 , Empty, nor a single character string, an exception is thrown.
Note |
|---|
This property is supported only in Internet Explorer 4.0 and later. |
The following example illustrates how to set and use the AccessKey property of a TextBox control.
Security 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. |
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>AccessKey Property of a Web Control</title>
</head>
<body>
<h3>AccessKey Property of a Web Control</h3>
<form id="form1" runat="server">
<asp:TextBox id="TextBox1"
AccessKey="Y"
Text="Press Alt-Y to get focus here"
Columns="45"
runat="server"/>
<br />
<asp:TextBox id="TextBox2"
AccessKey="Z"
Text="Press Alt-Z to get focus here"
Columns="45"
runat="server"/>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>AccessKey Property of a Web Control</title>
</head>
<body>
<h3>AccessKey Property of a Web Control</h3>
<form id="form1" runat="server">
<asp:TextBox id="TextBox1"
AccessKey="Y"
Text="Press Alt-Y to get focus here"
Columns="45"
runat="server"/>
<br />
<asp:TextBox id="TextBox2"
AccessKey="Z"
Text="Press Alt-Z to get focus here"
Columns="45"
runat="server"/>
</form>
</body>
</html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note
Security Note