Export (0) Print
Expand All

LoginView.AnonymousTemplate Property

Gets or sets the template to display to users who are not logged in to the Web site.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

'Declaration
<BrowsableAttribute(False)> _
<PersistenceModeAttribute(PersistenceMode.InnerProperty)> _
<TemplateContainerAttribute(GetType(LoginView))> _
Public Overridable Property AnonymousTemplate As ITemplate
<asp:LoginView>
	<AnonymousTemplate>ITemplate</AnonymousTemplate>
</asp:LoginView>

Property Value

Type: System.Web.UI.ITemplate
The ITemplate to display.

The AnonymousTemplate property specifies the content template to display to Web site users when they are not logged in to the Web site. This template is displayed when the Name property of the Page User property is Nothing.

The AnonymousTemplate template is never displayed to authenticated users. If the AnonymousTemplate property is empty, no content is displayed to users who are not logged in.

The following code example uses the template specified in the AnonymousTemplate template to display an invitation to sign up for personalized services.


<%@ 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">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <table style="text-align:center; width:300px; background-color:#fffacd">
                <tr style="background-color:#dcdcdc">
                    <td>Personal content</td>
                    <td align="right">
                        <asp:LoginStatus id="LoginStatus1" runat="Server"></asp:LoginStatus>
                    </td>
                </tr>
                <asp:LoginView id="LoginView1" runat="server">
                    <AnonymousTemplate>
                        <tr>
                            <td colspan="2">
                                <a href="createUser.aspx">Sign up</a> to personalize your account.
                            </td>
                        </tr>
                    </AnonymousTemplate>
                    <LoggedInTemplate>
                        <tr>
                            <td>
                                <asp:LoginName id="LoginName1" runat="Server" 
                                    FormatString="Welcome {0}">
                                </asp:LoginName>
                            </td>
                            <td align="right">
                                <a href="manageAccount.aspx">Edit info...</a>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                * Check e-mail * Add a link * Local weather *
                            </td>
                        </tr>
                    </LoggedInTemplate>
                </asp:LoginView>
            </table>
        </form>
    </body>
</html>


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft