HtmlForm.DefaultButton プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As HtmlForm Dim value As String value = instance.DefaultButton instance.DefaultButton = value
/** @property */ public String get_DefaultButton () /** @property */ public void set_DefaultButton (String value)
HtmlForm が読み込まれたときに既定のボタンとして表示されるボタン コントロールの ID。既定値は空の文字列 ("") です。


既定のボタンとして指定されたボタンは、ページが読み込まれた後、そのフォーム上の別のコントロールに移動せずに Enter キーを押した場合にサーバーにポストバックされます。DefaultButton プロパティに対してクリックされたときにイベントを発生させるコントロールを指定できます。DefaultButton プロパティによって参照されるコントロールの型が IButtonControl ではない場合、InvalidOperationException 例外がスローされます。
アプリケーションでマスタ ページを使用し、コンテンツ ページから DefaultButton プロパティを設定する場合は、IButtonControl ボタンの UniqueID プロパティを使用します。マスタ ページの詳細については、「ASP.NET マスター ページの概要」を参照してください。

DefaultButton プロパティを設定して、ポストバックの原因となる既定のコントロールを設定する方法を次のコード例に示します。
<%@ Page Language="VB" %> <script runat=Server> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Set the text of the two label controls. Label1.Text = "The DefaultButton property is set to " _ & Form1.DefaultButton.ToString & "<br/>" Label2.Text = "The DefaultFocus property is set to " _ & Form1.DefaultFocus.ToString End Sub </script> <html> <head> <title>HtmlForm DefaultButton and DefaultFocus Properties Example</title> </head> <body> <form id="Form1" defaultbutton="SubmitButton" defaultfocus="TextBox1" runat="server"> <h3>HtmlForm DefaultButton and DefaultFocus Properties Example</h3> TextBox1: <asp:textbox id="TextBox1" autopostback=true runat="server"> </asp:textbox> <br /> TextBox2: <asp:textbox id="TextBox2" autopostback=true runat="server"> </asp:textbox> <br /><br /> <asp:button id="SubmitButton" text="Submit" runat="server"> </asp:button> <asp:button id="CancelButton" text="Cancel" runat="server"> </asp:button> <hr /> <asp:label id="Label1" runat=Server> </asp:label> <asp:label id="Label2" runat=Server> </asp:label> </form> </body> </html>
<%@ page language="C#" %> <script runat="server"> void Page_Load(object sender, System.EventArgs e) { // Set the text of the two label controls. Label1.Text = "The DefaultButton property is set to " + Form1.DefaultButton.ToString() + "<br/>"; Label2.Text = "The DefaultFocus property is set to " + Form1.DefaultFocus.ToString(); } </script> <html> <head> <title>HtmlForm DefaultButton and DefaultFocus Properties Example</title> </head> <body> <form id="Form1" defaultbutton="SubmitButton" defaultfocus="TextBox1" runat="server"> <h3>HtmlForm DefaultButton and DefaultFocus Properties Example</h3> TextBox1: <asp:textbox id="TextBox1" autopostback=true runat="server"> </asp:textbox> <br /> TextBox2: <asp:textbox id="TextBox2" autopostback=true runat="server"> </asp:textbox> <br /><br /> <asp:button id="SubmitButton" text="Submit" runat="server"> </asp:button> <asp:button id="CancelButton" text="Cancel" runat="server"> </asp:button> <hr /> <asp:label id="Label1" runat=Server> </asp:label> <asp:label id="Label2" runat=Server> </asp:label> </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に収録されているすべての辞書からHtmlForm.DefaultButton プロパティを検索する場合は、下記のリンクをクリックしてください。

- HtmlForm.DefaultButton プロパティのページへのリンク