开发者

DotNetNuke Module Development: Displaying a Server Control only when the logged in user is an administrator or higher?

开发者 https://www.devze.com 2023-02-27 19:47 出处:网络
Can one specify inside an aspx page (without code-behind) only to display a user control if the logged in user has administrator rig开发者_如何转开发hts?I assume that you\'re talking about an ascx con

Can one specify inside an aspx page (without code-behind) only to display a user control if the logged in user has administrator rig开发者_如何转开发hts?


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)


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 %>" 
0

精彩评论

暂无评论...
验证码 换一张
取 消