Manage custom page controls based on the role security

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/17/2010 7:27:18 AM
Gravatar
Total Posts 137
When enough isn't

Manage custom page controls based on the role security

Hi

How do I ask for the Role of the User in MojoPortal?

I have a custom page with two controls on, A and B. What if I would like the page with control A to be visible to everyone, but only control B to be visible to adminstrators? How do I manage that with MojoPortals role based security system?

Example mentioned:

Script:

protected void Page_Load(object sender, EventArgs e)
{
ControlB.Visible = false;
if (Roles.IsUserInRole("Administrators")) ControlB.Visible = true;

}

...

Pages and Controls:

Home

--Contact Us

--Custom page (=aspx)

<asp:Listview ID="ControlA" ....

<asp:FormView ID="ControlB" visibility="false" .....

 

Best regards

Lars
 

6/17/2010 7:38:34 AM
Gravatar
Total Posts 18439

Re: Manage custom page controls based on the role security

You need 

using mojoPortal.Business.WebHelpers;

and this line should be changed as follows

if (WebUser.IsInRoles("Admins;")) ControlB.Visible = true;

or 

if(WebUser.IsAdmin) ControlB.Visible = true;

Hope it helps,

Joe

6/17/2010 7:49:34 AM
Gravatar
Total Posts 137
When enough isn't

Re: Manage custom page controls based on the role security

Excellent that worked!!

Thanks for rocket fast answer yes

Best regards

Lars

You must sign in to post in the forums. This thread is closed to new posts.