Login.LayoutTemplate Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the template used to display the Login control.
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
Property Value
An ITemplate that contains the template for displaying the Login control. The default value is null
.
- Attributes
Examples
The following code example creates a template for the Login control.
Important
This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
<%@ 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>
Remarks
The LayoutTemplate property contains the template that defines how the Login control is displayed to the user.
The following table lists the required and optional controls used in a Login control template.
ID or command name | Control type | Required/optional |
---|---|---|
UserName |
Any control that implements IEditableTextControl, including TextBox, or a custom or third-party control. | Required |
Password |
Any control that implements IEditableTextControl, including TextBox, or a custom or third-party control. | Required |
RememberMe |
CheckBox | Optional |
FailureText |
Any control that implements ITextControl. | Optional |
Login |
Any control that causes event bubbling. | Optional |
The Login control throws an HttpException exception if the layout template does not contain the required controls. No exception is thrown if you give an optional control ID to a control of the wrong type; however, the control is subsequently ignored by the Login control.
The login control can be any control that causes event bubbling, such as Button, LinkButton, or ImageButton. The control's command name property must be set to "Login".
When a template is used for the Login control, only the following properties affect the behavior of the control:
All properties inherited from WebControl. (For details, see the Login control members table.)
All other properties are inactive when a template is set for the Login control.