Version: 1.0 | 1.1 | 2.0 |

RoleView

in namespace DotVVM.Framework.Controls

Renders different content to the users which are in a specified role and users which are not.

Properties

Name Type Description Notes Default Value
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
inner element
static value
bindable
default
True
IsMemberTemplate ITemplate Gets or sets the content displayed to the users which are in one or more roles specified by the Roles property.
attribute
inner element
static value
bindable
default
IsNotMemberTemplate ITemplate Gets or sets the content displayed to the users which are not in any of the roles specified by the Roles property.
attribute
inner element
static value
bindable
default
RenderWrapperTag Boolean Gets or sets whether the control should render a wrapper element.
attribute
inner element
static value
bindable
default
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
inner element
static value
bindable
default
WrapperTagName String Gets or sets the name of the tag that wraps the Repeater.
attribute
inner element
static value
bindable
default
div

Events

Name Type Description

Usage & Scenarios

Allows to display different content to users that are member of a specific role.

HTML Rendered 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>

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">
  <IsMemberTemplate>
    I am a member.
  </IsMemberTemplate>
  <IsNotMemberTemplate>
    I am not a member.
  </IsNotMemberTemplate>
</dot:RoleView>

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message