Aracılığıyla paylaş


HtmlForm.DefaultFocus Özellik

Tanım

Denetim yüklendiğinde, form üzerindeki denetimi giriş odağıyla HtmlForm birlikte denetim olarak görüntülenecek şekilde alır veya ayarlar.

public:
 property System::String ^ DefaultFocus { System::String ^ get(); void set(System::String ^ value); };
public string DefaultFocus { get; set; }
member this.DefaultFocus : string with get, set
Public Property DefaultFocus As String

Özellik Değeri

ClientID yüklendiğinde giriş odağı olan denetim olarak görüntülenecek formdaki denetiminHtmlForm. Varsayılan değer boş bir dizedir ("").

Örnekler

Aşağıdaki kod örneğinde, form yüklendiğinde giriş odağı olan denetim olarak bir formda belirtilen denetimi görüntülemek için özelliğinin nasıl ayarlanacağı DefaultFocus gösterilmektedir. İşlendiğinde Form1 , ekleme noktasının içinde konumlandırıldığını TextBox1ve odaktaki denetimin bu olduğuna TextBox1 dikkat edin.

<%@ 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, 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 xmlns="http://www.w3.org/1999/xhtml" >

<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="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 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 xmlns="http://www.w3.org/1999/xhtml" >

<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>

Açıklamalar

DefaultFocus Denetim yüklendiğinde giriş odağıyla birlikte denetim olarak görüntülenecek formdaki denetime HtmlForm erişmek için özelliğini kullanın. Seçilebilen denetimler, odağın kendilerine olduğunu gösteren görsel bir ipucuyla görüntülenir. Örneğin, odaklanmalı bir TextBox denetim, ekleme noktası içinde konumlandırılmış olarak görüntülenir.

Odaklı denetim veya SetFocus yöntemleri kullanılarak Focus da ayarlanabilir. Bu yöntemlerin özelliğine DefaultFocus göre önceliği vardır. Denetimi odakla ayarlamak için bu yöntemlerden biri çağrılırsa, özelliğin DefaultFocus değeri yoksayılır.

Şunlara uygulanır

Ayrıca bkz.