次の方法で共有


WebControl.AccessKey プロパティ

Web サーバー コントロールにすばやく移動できるアクセス キーを取得または設定します。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public Overridable Property AccessKey As String
'使用
Dim instance As WebControl
Dim value As String

value = instance.AccessKey

instance.AccessKey = value
public virtual string AccessKey { get; set; }
public:
virtual property String^ AccessKey {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_AccessKey ()

/** @property */
public void set_AccessKey (String value)
public function get AccessKey () : String

public function set AccessKey (value : String)
適用できません。

プロパティ値

Web サーバー コントロールにすばやく移動できるアクセス キー。既定値は Empty で、このプロパティが設定されていないことを示します。

例外

例外の種類 条件

ArgumentOutOfRangeException

指定されたアクセス キーが null 参照 (Visual Basic では Nothing)、Empty、または単一の文字列のいずれでもありません。

解説

AccessKey プロパティを使用して、Web サーバー コントロールのショートカット キーを指定します。これによって、キーボードで Alt キーを押しながら、指定した文字を表すキーを押すことで、コントロールにすばやく移動できます。たとえば、コントロールのアクセス キーを文字列 "D" に設定した場合は、Alt キーを押しながら D キーを押すと、コントロールに移動できます。

AccessKey プロパティでは、単一の文字列だけを使用できます。このプロパティを null 参照 (Visual Basic では Nothing)、Empty、または単一の文字列のいずれでもない値に設定しようとすると、例外がスローされます。

メモメモ :

このプロパティは、Internet Explorer 4.0 以降でだけサポートされます。

トピック 場所
方法 : Web フォーム ページに Button Web サーバー コントロールを追加する (Visual Studio) Visual Studio での ASP .NET Web アプリケーションの作成
方法 : Visual Web Developer で Web ページのアクセシビリティをチェックする Visual Studio での ASP .NET Web アプリケーションの作成
方法 : Visual Web Developer で Web ページのアクセシビリティをチェックする Visual Studio ASP .NET での Web アプリケーションの作成
方法 : Web フォーム ページに Button Web サーバー コントロールを追加する (Visual Studio) Visual Studio ASP .NET での Web アプリケーションの作成
方法 : Visual Web Developer で Web ページのアクセシビリティをチェックする Visual Studio ASP .NET での Web アプリケーションの作成
方法 : Web フォーム ページに Button Web サーバー コントロールを追加する (Visual Studio) Visual Studio ASP .NET での Web アプリケーションの作成
方法 : Web フォーム ページに Button Web サーバー コントロールを追加する ASP .NET Web アプリケーションの作成

使用例

TextBox コントロールの AccessKey プロパティを設定して使用する方法の例を次に示します。

セキュリティに関するメモセキュリティに関するメモ :

この例には、ユーザー入力を受け付けるテキスト ボックスがあります。これにより、セキュリティが脆弱になる可能性があります。既定では、ASP.NET Web ページによって、ユーザー入力にスクリプトまたは HTML 要素が含まれていないかどうかが検証されます。詳細については、「スクリプトによる攻略の概要」を参照してください。

<%@ 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>
    
<%@ Page Language="JScript" 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 CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

WebControl クラス
WebControl メンバ
System.Web.UI.WebControls 名前空間

その他の技術情報

ASP.NET Web サーバー コントロールとブラウザの機能
Web サーバー コントロール構文
ASP.NET カスタム サーバー コントロールの開発