Button.Click イベント
アセンブリ: System.Web (system.web.dll 内)

public: virtual event EventHandler^ Click { void add (EventHandler^ value) sealed; void remove (EventHandler^ value) sealed; }

Click イベントは、Button コントロールがクリックされたときに発生します。通常このイベントは、送信ボタンなどの Button コントロールにコマンド名が関連付けられていない場合に使用されます。
イベント処理の詳細については、「イベントの利用」を参照してください。

Click イベントのイベント ハンドラを指定およびコーディングして、Button コントロールがクリックされたときに Web ページにメッセージを表示する方法を次のコード例に示します。
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub GreetingBtn_Click(ByVal sender As Object, _ ByVal e As EventArgs) ' When the button is clicked, ' change the button text, and disable it. Dim clickedButton As Button = sender clickedButton.Text = "...button clicked..." clickedButton.Enabled = False ' Display the greeting label text. GreetingLabel.Visible = True End Sub </script> <html > <head runat="server"> <title>Button Example</title> </head> <body> <form id="form1" runat="server"> <div> <h3>Simple Button Example</h3> <asp:Button id="Button1" Text="Click here for greeting..." OnClick="GreetingBtn_Click" runat="server"/> <br /> <br /> <asp:Label ID="GreetingLabel" runat="server" Visible=false Text="Hello World!" /> </div> </form> </body> </html>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Manually register the event-handling method for // the Click event of the Button control. Button1.Click += new EventHandler(this.GreetingBtn_Click); } void GreetingBtn_Click(Object sender, EventArgs e) { // When the button is clicked, // change the button text, and disable it. Button clickedButton = (Button)sender; clickedButton.Text = "...button clicked..."; clickedButton.Enabled = false; // Display the greeting label text. GreetingLabel.Visible = true; } </script> <html > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <h3>Simple Button Example</h3> <asp:Button id="Button1" Text="Click here for greeting..." OnClick="GreetingBtn_Click" runat="server"/> <br /> <br /> <asp:Label ID="GreetingLabel" runat="server" Visible=false Text="Hello World!" /> </div> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からButton.Click イベントを検索する場合は、下記のリンクをクリックしてください。

- Button.Click イベントのページへのリンク