Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

ASP.NET 2.0 Quickstart Tutorials

LoginView

The LoginView control automatically detects a user�s authentication status and role and matches that information to appropriate template of information to display to that user. The LoginView control consists of a collection of templates that can be associated with an authentication status or one or more role groups. For more information about the membership and roles system The LoginView control uses the click here . Since the LoginView derives from control (and not webcontrol) it has no style properties. It�s intent is to server as a non-visual container that automatically switches the template to be displayed based on the user�s designation. Note: The samples for this control use Master Pages to provide the information that is used to login a user. Learn more about Master Pages here.

Simple LoginView Sample

This sample demonstrates the Anonymous and LoggedIn templates for the LoginView control. Both of these templates are properties on the control and do not require using roles or adding a role group collection to the control.

VB LoginView
Run Sample View Source

LoginView RoleGroup Behaviors

In addition to the Anonymous and LoggedIn templates the LoginView control supports a collection of templates associated with different user roles. Since a user can be associated with multiple roles and a template can be associated with multiple roles it is important to understand how a the template is matched to the user�s role. The RoleGroup collection of templates is sequential (Anonymous and LoggedIn templates are handled outside of the sequence). All of the roles associated with the user are retrieved and the LoginView control looks for a template that matches any role associated with the user. The LoginView control evaluates each template from top to bottom in the collection and the first template associated with a role that the user belongs to is displayed to that user. There is no attempt by the control to merge all of the templates that the user is eligible to see based on all of their role group associations or to select the most privileged role group template. For example if a user is in both the customer and admin role groups and the customer template is sequentially before the admin template, that user will only ever see the customer template.

LoginView RoleGroup Behavior Sample

This sample contains two LoginView controls with the same role group templates. The order of the templates is different in the two controls. As a result users who belong to more then one role will see different content in the two controls.

VB LoginView Behaviors
Run Sample View Source

LoginView Templates

Since the LoginView control is heavily dependent on templates it is important to know how to programmatically access the controls inside the different templates. FindControl is the mechanism used to access the controls within the templates.

LoginView FindControl Template Sample

In this sample FindControl is used to access the selection of a DropDownList within the Admin template and display the value of the selection in a label.

VB LoginView Templates
Run Sample View Source