HtmlForm.DefaultFocus Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Denetim yüklendiğinde, formdaki denetimi giriş odağıyla HtmlForm 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 denetimin HtmlForm öğesi. Varsayılan değer boş bir dizedir ("").
Örnekler
Aşağıdaki kod örneği, form yüklendiğinde giriş odağı olan denetim olarak bir formda belirtilen denetimi görüntülemek için özelliğinin nasıl ayarlandığını DefaultFocus gösterir. İşlendiğinde Form1
, ekleme noktasının içinde TextBox1
konumlandırıldığını ve 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ğı olan denetim olarak görüntülemek üzere formdaki denetime HtmlForm erişmek için özelliğini kullanın. Seçilebilen denetimler, odağın kendilerine geldiğini gösteren görsel bir ipucuyla birlikte görüntülenir. Örneğin, odaklı bir TextBox denetim, ekleme noktası içinde konumlandırılmış olarak görüntülenir.
Odaklanan 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.