aspxtreme

System.Web.UI.WebControls Namespace


.NET Framework version 2.0

Displays the appropriate content template for a given user, based on the user's authentication status and role membership.

LoginView Class Members

Collapse   Constructors

Visibility Constructor Parameters
public LoginView ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public AnonymousTemplate ITemplate [ Get , Set ]
public Controls ControlCollection [ Get ]
public EnableTheming Boolean [ Get , Set ]
public LoggedInTemplate ITemplate [ Get , Set ]
public RoleGroups RoleGroupCollection [ Get ]
public SkinID String [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
public DataBind ( ) Void
public Focus ( ) Void
protected OnViewChanged ( EventArgs e ) Void
protected OnViewChanging ( EventArgs e ) Void
protected SetDesignModeState ( IDictionary data ) Void

Collapse   Events

Multicast Name Type
multicast ViewChanged EventHandler
multicast ViewChanging EventHandler

Remarks

The LoginView control displays different Web site content templates ( or "views" ) for different users, based on whether the user is authenticated and, if so, which Web site roles he or she belongs to.

The template stored in the AnonymousTemplate property is displayed to any visitor to the Web site who has not logged in. Once a user is logged in, the site displays either a template associated with one of the user's roles in the RoleGroups property or the default template specified in the LoggedInTemplate property.

The LoginView control manages switching among the various templates once you assign templates to any of the three template properties of the LoginView class:

  • AnonymousTemplate Specifies the template to display to users who are not logged in to the Web site. Users who are logged in will never see this template.
  • LoggedInTemplate Specifies the default template to display to users who are logged in to the Web site but do not belong to any role groups with defined templates.
  • RoleGroups Specifies the template to display to logged-in users who are members of roles with defined role-group templates. Content templates are associated with particular sets of roles in RoleGroup instances.

Role-group templates are searched in the order they are defined in the source. The first matching role-group template is displayed to the user. If a user is a member of more than one role, the first role-group template that matches any of the user's roles is used. If more than one template is associated with a single role, only the first defined template is used.

The following table describes the behavior of the LoginView control when various combinations of templates are used.

LoggedIn Template Property Anonymous Template Property RoleGroups Property LoginView behavior
Not set Not set Not set Displays no content.
Set Not set Not set Displays content only when the user is logged in.
Not set Set Not set Displays content only when the user is not logged in.
Not set Not set Set Displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, displays no content.
Set Set Not set If the user is logged in, displays the template specified in the LoggedInTemplate property. If the user in not logged in, displays the template specified in the AnonymousTemplate property.
Set Set Set If the user is logged in, displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, displays the template specified in the LoggedInTemplate property. If the user is not logged in, displays the template specified in the AnonymousTemplate property.
Set Not set Set If the user is logged in, displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, displays the template specified in the LoggedInTemplate property. If the user is not logged in, nothing is displayed.
Not set Set Set If the user is logged in, displays the first template in the RoleGroups collection that matches one of the user's roles. If no match is found, nothing is displayed. If the user is not logged in, displays the template specified in the AnonymousTemplate property.

The AnonymousTemplate and LoggedInTemplate can be used with any authentication scheme that sets the Name property of the Page object's User property. You must configure role management to use the RoleGroups property to define templates base on the user's role on the Web site. For more information, see Introduction to Role Management.

The Focus method does not set the initial focus of the Web page to the LoginView control, or any of its child controls. Controls contained in the LoginView control are created after the PreRender event. To set the focus to a child control contained by the LoginView, handle the On_PreRender and call its Focus method. You can also use the ViewChanging and ViewChanged events to programmatically access the controls in the LoginView control templates.

For examples illustrating use of this control, see the individual member types of this class. For syntax information, see LoginView in ASP.NET Syntax for Web Controls.

See Also

ASP.NET Login Controls   LoginView Web Server Control



Books and more ...


Suggested Reading

Need a break ?



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme