Exporter (0) Imprimer
Développer tout
EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

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)

public virtual string AccessKey { get; set; }
/** @property */
public String get_AccessKey ()

/** @property */
public void set_AccessKey (String value)

public function get AccessKey () : String

public function set AccessKey (value : String)

Not applicable.

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.

Exception typeCondition

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 (Visual Studio).

<%@ 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 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Ajouts de la communauté

AJOUTER
Microsoft réalise une enquête en ligne pour recueillir votre opinion sur le site Web de MSDN. Si vous choisissez d’y participer, cette enquête en ligne vous sera présentée lorsque vous quitterez le site Web de MSDN.

Si vous souhaitez y participer,
Afficher:
© 2015 Microsoft