Share via


Login.TextBoxStyle Properti

Definisi

Mendapatkan referensi ke kumpulan properti yang menentukan tampilan kotak teks dalam Login kontrol.

public:
 property System::Web::UI::WebControls::Style ^ TextBoxStyle { System::Web::UI::WebControls::Style ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.Style TextBoxStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.TextBoxStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property TextBoxStyle As Style

Nilai Properti

Referensi ke Style yang berisi properti yang menentukan tampilan kotak teks.

Atribut

Contoh

Contoh kode berikut mengatur warna latar belakang dan teks kontrol Nama pengguna dan Kata Sandi TextBox dengan mengatur properti pada objek yang Style dirujuk oleh TextBoxStyle properti .

Penting

Contoh ini berisi kotak teks yang menerima input pengguna, yang merupakan potensi ancaman keamanan. Secara default, ASP.NET halaman Web memvalidasi bahwa input pengguna tidak menyertakan elemen skrip atau HTML. Untuk informasi selengkapnya, lihat Gambaran Umum Eksploitasi Skrip.

<%@ 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 OnLoginError(object server, EventArgs e) 
{
    Login1.TextBoxStyle.BackColor = System.Drawing.Color.Red;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server"
                OnLoginError="OnLoginError">
                <TextBoxStyle 
                    BorderStyle="Inset" 
                    ForeColor="#FFFFC0" 
                    BackColor="Gray">
                </TextBoxStyle>
            </asp:Login>

        </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 OnLoginError(ByVal sender As Object, ByVal e As EventArgs)
    Login1.TextBoxStyle.BackColor = System.Drawing.Color.Red
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server"
                OnLoginError="OnLoginError">
                <TextBoxStyle 
                    BorderStyle="Inset" 
                    ForeColor="#FFFFC0" 
                    BackColor="Gray">
                </TextBoxStyle>
            </asp:Login>

        </form>
    </body>
</html>

Keterangan

Properti TextBoxStyle menentukan tampilan kontrol Nama pengguna dan Kata Sandi TextBox dalam Login kontrol. Properti ini bersifat baca-saja; namun, Anda dapat mengatur properti objek yang Style dikembalikannya. Anda dapat mengatur properti ini secara deklaratif dalam formulir Property-Subproperty, di mana Subproperty mewakili properti Style kelas (misalnya, TextBoxStyle-ForeColor). Anda dapat mengatur properti secara terprogram dalam formulir Property.Subproperty (misalnya, TextBoxStyle.ForeColor).

Pengaturan umum mencakup warna latar belakang kustom, warna teks, dan properti font. Properti TextBoxStyle menentukan tampilan kotak teks nama pengguna dan kata sandi.

Pengaturan gaya untuk TextBoxStyle properti digabungkan dengan pengaturan gaya untuk Login kontrol. Pengaturan apa pun yang TextBoxStyle dibuat di properti mengambil alih pengaturan terkait di properti Login kontrol.

Properti gaya berikut Login ini ditimpa oleh TextBoxStyle pengaturan:

Saat Anda menggunakan templat untuk menentukan tampilan Login kontrol, TextBoxStyle properti tidak berpengaruh.

Berlaku untuk

Lihat juga