ImageButton.Command イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ImageButton.Command イベントの意味・解説 

ImageButton.Command イベント

ImageButton がクリックされたときに発生します

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

Public Event Command As
 CommandEventHandler
Dim instance As ImageButton
Dim handler As CommandEventHandler

AddHandler instance.Command, handler
public event CommandEventHandler Command
public:
virtual event CommandEventHandler^ Command {
    void add (CommandEventHandler^ value) sealed;
    void remove (CommandEventHandler^ value) sealed;
}
/** @event */
public final void add_Command (CommandEventHandler
 value)

/** @event */
public final void remove_Command (CommandEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

Command イベントハンドラ指定およびコード化して、どの 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>

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


このページでは「.NET Framework クラス ライブラリ リファレンス」からImageButton.Command イベントを検索した結果を表示しています。
Weblioに収録されているすべての辞書からImageButton.Command イベントを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からImageButton.Command イベント を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ImageButton.Command イベント」の関連用語

ImageButton.Command イベントのお隣キーワード
検索ランキング

   

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



ImageButton.Command イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS