RoleView
in namespace DotVVM.Framework.Controls
Renders different content to the users which are in a specified role and users which are not.
Usage & Scenarios
Allows to display different content to users that are member of a specific role.
Sample 1: RoleView
The Roles
property contains a comma-separated list of roles.
The IsMemberTemplate
defines the content displayed to the users who are member of at least one of the role in the Roles
property.
The IsNotMemberTemplate
defines the content displayed to other users.
By default, the control is hidden completely to the users who are not authenticated. If you want to display the IsNotMemberTemplate
even to the anonymous users, set the HideForAnonymousUsers
property to false
.
<dot:RoleView Roles="admin,moderator,tester" HideForAnonymousUsers="false">
<IsMemberTemplate>
I am a member.
</IsMemberTemplate>
<IsNotMemberTemplate>
I am not a member.
</IsNotMemberTemplate>
</dot:RoleView>
Properties
Name | Type | Description | Notes | Default Value | |
---|---|---|---|---|---|
Attributes | Dictionary<String,Object> |
attribute
static value
|
null | ||
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. |
attribute
static value
bindable
|
null | |
HideForAnonymousUsers | Boolean | Gets or sets whether the control will be hidden completely to anonymous users. If set to false, the IsNotMemberTemplate will be rendered to anonymous users. |
attribute
static value
|
True | |
ID | String | Gets or sets the unique control ID. |
attribute
static value
|
null | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
IsMemberTemplate | ITemplate | Gets or sets the content displayed to the users which are in one or more roles specified by the Roles property. |
inner element
static value
default
|
null | |
IsNotMemberTemplate | ITemplate | Gets or sets the content displayed to the users which are not in any of the roles specified by the Roles property. |
inner element
static value
|
null | |
RenderWrapperTag | Boolean | Gets or sets whether the control should render a wrapper element. |
attribute
static value
|
False | |
Roles | String[] | Gets or sets a comma-separated list of roles. The user must be a member of one or more of these roles. |
attribute
static value
|
null | |
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True | |
WrapperTagName | String | Gets or sets the name of the tag that wraps the Repeater. |
attribute
static value
|
div |
HTML produced by the control
The control renders the contents of the IsMemberTemplate
or IsNotMemberTemplate
property. Optionally you can enable wrapper tag rendering using
the RenderWrapperTag
property. The tag name can be changed using the WrapperTagName
property.
<div>
<!-- Contents of the IsMemberTemplate or IsNotMemberTemplate -->
</div>