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

Dim instance As HtmlForm Dim value As String value = instance.DefaultFocus instance.DefaultFocus = value
/** @property */ public String get_DefaultFocus () /** @property */ public void set_DefaultFocus (String value)
HtmlForm が読み込まれたときに入力フォーカスのあるコントロールとして表示するフォーム上のコントロールの ID。既定値は空の文字列 ("") です。

DefaultFocus プロパティを使用して、HtmlForm コントロールが読み込まれたときに入力フォーカスのあるコントロールとして表示するフォーム上のコントロールにアクセスします。選択できるコントロールは、そのコントロールにフォーカスがあることが視覚的にわかるように表示されます。たとえば、フォーカスのある TextBox コントロールは、挿入ポインタがその内部に配置された状態で表示されます。
フォーカスのあるコントロールは、Focus メソッドまたは SetFocus メソッドを使用して設定することもできます。これらのメソッドは、DefaultFocus プロパティよりも優先されます。これらのメソッドのいずれかを呼び出して、フォーカスのあるコントロールを設定すると、DefaultFocus プロパティの値は無視されます。

指定したコントロールを、フォームを読み込んだときに入力フォーカスのあるコントロールとしてフォーム上に表示するように DefaultFocus プロパティを設定する方法を次のコード例に示します。Form1 が表示されると、挿入ポインタが TextBox1 に配置されることに注目してください。これは TextBox1 コントロールにフォーカスがあることを示します。
<%@ 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.DefaultFocus プロパティを検索する場合は、下記のリンクをクリックしてください。

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