Bagikan melalui


Login.LayoutTemplate Properti

Definisi

Mendapatkan atau mengatur templat yang digunakan untuk menampilkan Login kontrol.

public:
 virtual property System::Web::UI::ITemplate ^ LayoutTemplate { System::Web::UI::ITemplate ^ get(); void set(System::Web::UI::ITemplate ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.Login))]
public virtual System.Web.UI.ITemplate LayoutTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.Login))>]
member this.LayoutTemplate : System.Web.UI.ITemplate with get, set
Public Overridable Property LayoutTemplate As ITemplate

Nilai Properti

Yang ITemplate berisi templat untuk menampilkan Login kontrol. Nilai defaultnya adalah null.

Atribut

Contoh

Contoh kode berikut membuat templat untuk Login kontrol.

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#" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</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">
                <LayoutTemplate>
                    <table>
                        <tr>
                            <td colspan="2" align="center">
                                Login
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                Enter your user name and password to log in.
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table>
                                    <tr>
                                        <td>
                                            User name:
                                        </td>
                                        <td>
                                            <asp:TextBox id="UserName" runat="server"></asp:TextBox>
                                            <asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" Text="*"></asp:requiredfieldvalidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Password:</td>
                                        <td>
                                            <asp:TextBox id="Password" runat="server" textMode="Password"></asp:TextBox>
                                            <asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" Text="*"></asp:requiredfieldvalidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:Checkbox id="RememberMe" runat="server" Text="Remember my login"></asp:Checkbox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td valign="middle">
                                <ul>
                                    <li><a href="newAccount.aspx">Create a new account...</a></li>
                                    <li><a href="getPass.aspx">Forgot your password?</a></li>
                                    <li><a href="help.aspx">Get help logging in...</a></li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <asp:button id="Login" CommandName="Login" runat="server" Text="Login"></asp:button>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <asp:Literal id="FailureText" runat="server"></asp:Literal></td>
                        </tr>
                    </table>
                </LayoutTemplate>
            </asp:Login>
        </form>
    </body>
</html>
<%@ Page Language="VB" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</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">
                <LayoutTemplate>
                    <table>
                        <tr>
                            <td colspan="2" align="center">
                                Login
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                Enter your user name and password to log in.
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table>
                                    <tr>
                                        <td>
                                            User name:
                                        </td>
                                        <td>
                                            <asp:TextBox id="UserName" runat="server"></asp:TextBox>
                                            <asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" Text="*"></asp:requiredfieldvalidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Password:</td>
                                        <td>
                                            <asp:TextBox id="Password" runat="server" textMode="Password"></asp:TextBox>
                                            <asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" Text="*"></asp:requiredfieldvalidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">
                                            <asp:Checkbox id="RememberMe" runat="server" Text="Remember my login"></asp:Checkbox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td valign="middle">
                                <ul>
                                    <li><a href="newAccount.aspx">Create a new account...</a></li>
                                    <li><a href="getPass.aspx">Forgot your password?</a></li>
                                    <li><a href="help.aspx">Get help logging in...</a></li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <asp:button id="Login" CommandName="Login" runat="server" Text="Login"></asp:button>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <asp:Literal id="FailureText" runat="server"></asp:Literal></td>
                        </tr>
                    </table>
                </LayoutTemplate>
            </asp:Login>
        </form>
    </body>
</html>

Keterangan

Properti LayoutTemplate berisi templat yang menentukan bagaimana Login kontrol ditampilkan kepada pengguna.

Tabel berikut ini mencantumkan kontrol yang diperlukan dan opsional yang Login digunakan dalam templat kontrol.

ID atau nama perintah Jenis kontrol Diperlukan/opsional
UserName Kontrol apa pun yang mengimplementasikan IEditableTextControl, termasuk TextBox, atau kontrol kustom atau pihak ketiga. Diperlukan
Password Kontrol apa pun yang mengimplementasikan IEditableTextControl, termasuk TextBox, atau kontrol kustom atau pihak ketiga. Diperlukan
RememberMe CheckBox Opsional
FailureText Kontrol apa pun yang mengimplementasikan ITextControl. Opsional
Login Kontrol apa pun yang menyebabkan peristiwa menggelegak. Opsional

Kontrol Login melemparkan HttpException pengecualian jika templat tata letak tidak berisi kontrol yang diperlukan. Tidak terkecuali jika Anda memberikan ID kontrol opsional ke kontrol jenis yang salah; namun, kontrol kemudian diabaikan oleh Login kontrol.

Kontrol login dapat menjadi kontrol apa pun yang menyebabkan peristiwa menggelegak, seperti Button, , LinkButtonatau ImageButton. Properti nama perintah kontrol harus diatur ke "Masuk".

Saat templat digunakan untuk Login kontrol, hanya properti berikut yang memengaruhi perilaku kontrol:

Semua properti lain tidak aktif saat templat diatur untuk Login kontrol.

Berlaku untuk

Lihat juga