Friday 27 September 2013

SPSecurityTrimmedControl

You can use SPSecurityTrimmedControl if you want to display the content (HTML code or other controls) based on the user's permission.

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" PermissionsString="ApproveItems" runat="server" >
         
</SharePoint:SPSecurityTrimmedControl>


The PermissionsString attribute of <SharePoint:SPSecurityTrimmedControl /> defines the permissions the user must have in order to view the content. Some of the built-in SharePoint permissions that you can use as a value of this attribute are ApproveItems, ManageLists, AddListItems, EditListItems, DeleteListItems, ViewListItems, ManageAlerts, ViewVersions, DeleteVersions and CancelCheckout. (To see the complete list of possible values, click here.)


In the below example, the current user will be able to see the Approve button only if he has "ApproveItems" permission defined in the PermissionsString.

<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" PermissionsString="ApproveItems" runat="server" >
          <asp:Button runat="server" class="ms-ButtonHeightWidth2" OnClick="BtnApprove_Click" Text="Approve" id="btnApprove" />
</SharePoint:SPSecurityTrimmedControl>


No comments:

Post a Comment