This simple and extremely powerful control allows you to display:

–  a different set of controls for anonymous and authenticated users.

–  different content based on which roles the currently logged-in user is assigned to

The LoginView control is a template control with different types of templates:

–  one for anonymous users

–  one for authenticated users

–  one for supporting role-based templates

 

<asp:LoginView ID=”LoginViewCtrl” runat=”server”>

<AnonymousTemplate>

<h2>You are anonymous</h2>

</AnonymousTemplate>

<LoggedInTemplate>

<h2>You are logged in</h2>

Submit your comment: <asp:TextBox runat=”server” ID=”CommentText” />

<br />

<asp:Button runat=”server” ID=”SubmitCommentAction” Text=”Submit” />

</LoggedInTemplate>

</asp:LoginView>

 

You can handle two events, supported by the control, for initializing content controls of different templates appropriately before they are displayed:

– ViewChanging, which is raised before the control displays content defined in another template

– ViewChanged, which is raised after the control has changed the content display from one template to another