Login.LayoutTemplate Właściwość

Definicja

Pobiera lub ustawia szablon używany do wyświetlania kontrolki Login .

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

Wartość właściwości

ITemplate

Element ITemplate zawierający szablon do wyświetlania kontrolki Login . Wartość domyślna to null.

Atrybuty

Przykłady

Poniższy przykład kodu tworzy szablon dla kontrolki Login .

Ważne

Ten przykład zawiera pole tekstowe, które akceptuje dane wejściowe użytkownika, co jest potencjalnym zagrożeniem bezpieczeństwa. Domyślnie ASP.NET strony sieci Web weryfikują, czy dane wejściowe użytkownika nie zawierają skryptów ani elementów HTML. Aby uzyskać więcej informacji, zobacz Omówienie luk w zabezpieczeniach skryptów.

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

Uwagi

Właściwość LayoutTemplate zawiera szablon, który definiuje sposób wyświetlania Login kontrolki użytkownikowi.

W poniższej tabeli wymieniono wymagane i opcjonalne kontrolki używane w szablonie kontrolki Login .

Identyfikator lub nazwa polecenia Typ kontrolki Wymagane/opcjonalne
UserName Każda kontrolka, która implementuje kontrolkę IEditableTextControl, w tym TextBoxkontrolkę niestandardową lub inną. Wymagane
Password Każda kontrolka, która implementuje kontrolkę IEditableTextControl, w tym TextBoxkontrolkę niestandardową lub inną. Wymagane
RememberMe CheckBox Opcjonalne
FailureText Dowolna kontrolka, która implementuje ITextControl. Opcjonalne
Login Każda kontrolka, która powoduje bubbling zdarzenia. Opcjonalne

Kontrolka Login zgłasza HttpException wyjątek, jeśli szablon układu nie zawiera wymaganych kontrolek. W przypadku podania opcjonalnego identyfikatora kontrolki do kontrolki nieprawidłowego typu nie jest zgłaszany żaden wyjątek; jednak kontrolka jest następnie ignorowana przez kontrolkę Login .

Kontrolka logowania może być dowolną kontrolką, która powoduje bubbling zdarzenia, takie jak Button, LinkButtonlub ImageButton. Właściwość nazwy polecenia kontrolki musi być ustawiona na "Login".

Gdy szablon jest używany dla kontrolki Login , tylko następujące właściwości wpływają na zachowanie kontrolki:

Wszystkie inne właściwości są nieaktywne, gdy szablon jest ustawiony dla kontrolki Login .

Dotyczy

Zobacz też