This article describes how to show or hide particular bizform´s field(s) per user´s role.
It can be done in the code-behind of your Bizform web part (CMSWebParts/Bizforms/bizform.ascx.cx), in some appropriate handler (e.g. Load or OnPreRender – see bizform´s properties).
You can check if the current user is in the requested role using the following code:

if (CMS.CMSHelper.CMSContext.CurrentUser.IsInRole("CMSEditor", CMS.CMSHelper.CMSContext.CurrentSiteName))

{

//the current user is member of the CMSEditor role

}


Then you can hide/show appropriate control on your bizform. Let´s say that you want to hide some field of TextBox type. You can use this code for this purpose:

Version 5.5 R2 and older versions:

TextBox myField = (TextBox)viewBiz.BasicForm.FieldControls["NameOfAppropriateField"];
myField.Visible = false;


Version 6:

((CMS.FormControls.EditingFormControl)
viewBiz.BasicForm.FieldEditingControls["NameOfAppropriateField "]).Enabled = false;



An alternative approach could be to use FormControl instead of TextBox and manage visibility of this FormControl according to current user´s role.

-bp-



See also: Modifying the code of standard web parts


Applies to: Kentico CMS 4.x, update for Kentico CMS 6.0
Created on 10/9/2009 5:15:23 AM in
 


Sitemap | Content Management System | E-commerce Software | Social Networking Software | Intranet | Online Marketing Solution | Copyright © 2004-2012 Kentico Software | Powered by Kentico CMS