LoginView.RoleGroups Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of role groups that associate content templates with particular roles.
public:
virtual property System::Web::UI::WebControls::RoleGroupCollection ^ RoleGroups { System::Web::UI::WebControls::RoleGroupCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.Themeable(false)]
public virtual System.Web.UI.WebControls.RoleGroupCollection RoleGroups { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.Themeable(false)>]
member this.RoleGroups : System.Web.UI.WebControls.RoleGroupCollection
Public Overridable ReadOnly Property RoleGroups As RoleGroupCollection
Property Value
A RoleGroupCollection object that contains the defined role-group templates.
- Attributes
Examples
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" "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">
<asp:LoginView id="LoginView1" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="author">
<ContentTemplate>
<ul>
<li>Add a new article.</li>
<li>Review editorial changes.</li>
<li>View article requests.</li>
</ul>
</ContentTemplate>
</asp:RoleGroup>
<asp:RoleGroup Roles="editor">
<ContentTemplate>
<ul>
<li>Review articles.</li>
<li>Submit edited article.</li>
</ul>
</ContentTemplate>
</asp:RoleGroup>
<asp:RoleGroup Roles="publisher">
<ContentTemplate>
<ul>
<li>Make article request.</li>
<li>Publish reviewed article.</li>
</ul>
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
</form>
</body>
</html>
<%@ 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">
<asp:LoginView id="LoginView1" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="author">
<ContentTemplate>
<ul>
<li>Add a new article.</li>
<li>Review editorial changes.</li>
<li>View article requests.</li>
</ul>
</ContentTemplate>
</asp:RoleGroup>
<asp:RoleGroup Roles="editor">
<ContentTemplate>
<ul>
<li>Review articles.</li>
<li>Submit edited article.</li>
</ul>
</ContentTemplate>
</asp:RoleGroup>
<asp:RoleGroup Roles="publisher">
<ContentTemplate>
<ul>
<li>Make article request.</li>
<li>Publish reviewed article.</li>
</ul>
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
</form>
</body>
</html>
Remarks
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.