2
votes

Can one specify inside an aspx page (without code-behind) only to display a user control if the logged in user has administrator rights?

2

2 Answers

4
votes

I assume that you're talking about an ascx control, since there isn't any real integration of aspx pages in DotNetNuke.

Ideally this kind of permission would be configured in the module's settings, rather than hardcoded in. However, if that's not possible for whatever reason, you can check if the user is an administrator via the following code, which you can put in a code block in your ascx control (why can't you use a code-behind?):

UserInfo.IsInRole(PortalSettings.AdministratorRoleName)
3
votes

The easiest thing to do, but this will only work if only administrators have edit rights for the module, is to add the following to the user control tag:

Visible="<%# IsEditable %>"