ImageButton.CommandArgument プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ImageButton.CommandArgument プロパティの意味・解説 

ImageButton.CommandArgument プロパティ

CommandName プロパティに関する追加情報を提供するオプション引数を取得または設定します。

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

<ThemeableAttribute(False)> _
<BindableAttribute(True)> _
Public Property CommandArgument As
 String
Dim instance As ImageButton
Dim value As String

value = instance.CommandArgument

instance.CommandArgument = value
[ThemeableAttribute(false)] 
[BindableAttribute(true)] 
public string CommandArgument { get;
 set; }
[ThemeableAttribute(false)] 
[BindableAttribute(true)] 
public:
virtual property String^ CommandArgument {
    String^ get () sealed;
    void set (String^ value) sealed;
}
/** @property */
public final String get_CommandArgument ()

/** @property */
public final void set_CommandArgument (String
 value)
public final function get
 CommandArgument () : String

public final function set
 CommandArgument (value : String)

プロパティ値
CommandName プロパティを補足するオプション引数。

解説解説

場合によっては、複数の ImageButton コントロールが関連付けられ、CommandName プロパティの値として、Sort などの同じ値を共有することがあります。このプロパティを使用して、CommandName プロパティに、Ascending などの実行するコマンドに関する追加情報を補足します。CommandName プロパティおよび CommandArgument プロパティの各値は、通常、OnCommand イベント ハンドラで使用され、ImageButton コントロールがクリックされたときに実行するアクションを決定します。

このプロパティを、テーマまたはスタイル シート テーマを使用して設定することはできません。詳細については、ThemeableAttribute、ASP.NET のテーマとスキンの概要 の各トピックを参照してください。

使用例使用例

CommandArgument プロパティを使用して、コマンド引数と ImageButton コントロールを関連付ける方法の例を次に示します。

メモメモ

次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。

<%@ Page Language="VB" AutoEventWireup="True"
 %>
<html>
<head>

   <script language="VB" runat="server">

      Sub ImageButton_Command(sender As Object,
 e As CommandEventArgs) 
         If (e.CommandName = "Sort")
 And (e.CommandArgument = "Ascending")
 Then
            Label1.Text = "You clicked the Sort Ascending Button"
         Else
            Label1.Text = "You clicked the Sort Descending Button"
         End If
      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3>ImageButton CommandName Sample</h3>

      Click an image.<br><br>

      <asp:ImageButton id="imagebutton1" runat="server"
           AlternateText="Sort Ascending"
           ImageUrl="images/pict.jpg"
           OnCommand="ImageButton_Command"
           CommandName="Sort"
           CommandArgument="Ascending"/>

      <asp:ImageButton id="imagebutton2" runat="server"
           AlternateText="Sort Descending"
           ImageUrl="images/pict2.jpg"
           OnCommand="ImageButton_Command"
           CommandName="Sort"
           CommandArgument="Descending"/>

      <br><br>
    
      <asp:label id="Label1" runat="server"/>

   </form>

</body>
</html>

<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

   <script language="C#" runat="server">

      void ImageButton_Command(object sender, CommandEventArgs
 e) 
      {
         if (e.CommandName == "Sort" && e.CommandArgument
 == "Ascending")
            Label1.Text = "You clicked the Sort Ascending Button";
         else
            Label1.Text = "You clicked the Sort Descending Button";
      }

   </script>

</head>

<body>

   <form runat="server">

      <h3>ImageButton CommandName Sample</h3>

      Click an image.<br><br>

      <asp:ImageButton id="imagebutton1" runat="server"
           AlternateText="Sort Ascending"
           ImageUrl="images/pict.jpg"
           OnCommand="ImageButton_Command"
           CommandName="Sort"
           CommandArgument="Ascending"/>

      <asp:ImageButton id="imagebutton2" runat="server"
           AlternateText="Sort Descending"
           ImageUrl="image/pict2.jpg"
           OnCommand="ImageButton_Command"
           CommandName="Sort"
           CommandArgument="Descending"/>

      <br><br>
    
      <asp:label id="Label1" runat="server"/>

   </form>

</body>
</html>

<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>

   <script language="JSCRIPT" runat="server">

      function ImageButton_Command(sender : Object, e : CommandEventArgs){
         if(e.CommandName == "Sort" && e.CommandArgument
 == "Ascending")
            Label1.Text = "You clicked the Sort Ascending Button"
         else
            Label1.Text = "You clicked the Sort Descending Button"
      }

   </script>

</head>

<body>

   <form runat="server">

      <h3>ImageButton CommandName Sample</h3>

      Click an image.<br><br>

      <asp:ImageButton id="imagebutton1" runat="server"
           AlternateText="Sort Ascending"
           ImageUrl="images/pict.jpg"
           OnCommand="ImageButton_Command"
           CommandName="Sort"
           CommandArgument="Ascending"/>

      <asp:ImageButton id="imagebutton2" runat="server"
           AlternateText="Sort Descending"
           ImageUrl="images/pict2.jpg"
           OnCommand="ImageButton_Command"
           CommandName="Sort"
           CommandArgument="Descending"/>

      <br><br>
    
      <asp:label id="Label1" runat="server"/>

   </form>

</body>
</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

ImageButton.CommandArgument プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ImageButton.CommandArgument プロパティのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS