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
property icon 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
property icon 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
null
property icon 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
null
property icon RenderWrapperTag Boolean Gets or sets whether the control should render a wrapper element.
attribute
inner element
static value
bindable
default
False
property icon 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
null
property icon WrapperTagName String Gets or sets the name of the tag that wraps the Repeater.
attribute
inner element
static value
bindable
default
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>