This documentation is archived and is not being maintained.

LoginView.RoleGroups Property

Note: This property is new in the .NET Framework version 2.0.

Gets a collection of role groups that associate content templates with particular roles.

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

public virtual RoleGroupCollection RoleGroups { get; }
/** @property */
public RoleGroupCollection get_RoleGroups ()

public function get RoleGroups () : RoleGroupCollection

Property Value

A RoleGroupCollection object that contains the defined role-group templates.

The RoleGroups property contains the content templates associated with various roles on the Web site. The collection in the RoleGroups property is searched in the order in which templates 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 will be used.

If a logged-in user does not belong to any role contained in the role-group collection, the site displays the content template specified in the LoggedInTemplate property. Anonymous users are never shown any template contained in the RoleGroups collection.

You must configure role management to use the RoleGroups property to define templates based on the user's role on the Web site. For more information, see Understanding Role Management.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins Overview.

The following code example demonstrates using the RoleGroups collection. Because the AnonymousTemplate and LoggedInTemplate properties are not set, the content is displayed only to users who belong to roles with a defined content template.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<SCRIPT runat="server">

        <FORM runat="server">
            <asp:LoginView id="LoginView1" runat="server">
                    <asp:RoleGroup Roles="author">
                                <li>Add a new article.</li>
                                <li>Review editorial changes.</li>
                                <li>View article requests.</li>
                    <asp:RoleGroup Roles="editor">
                                <li>Review articles.</li>
                                <li>Submit edited article.</li>
                    <asp:RoleGroup Roles="publisher">
                                <li>Make article request.</li>
                                <li>Publish reviewed article.</li>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0