2

I notice that using the security trimming control (say for RibbonBox) only hides the content, I want something like display:none, can we achieve this?:

CASE 1:

  <Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="EditListItems">
    <div id="ribbonBox" style="background-color:red">

    //code of ribbon with the buttons for edit/share/follow/fullscreen

    </div>
    </Sharepoint:SPSecurityTrimmedControl>

CASE 2:

 <div id="ribbonBox" style="background-color:red">
<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="EditListItems">

        //code of ribbon with the buttons for edit/share/follow/fullscreen

        </Sharepoint:SPSecurityTrimmedControl>
</div>

When a user with only read permission logs in, then he cannot see the contents of the div tag (this is perfect!), however:-

CASE 1. The div itself is not collapsed.

CASE 2. The div does not get the red color.

How can I achieve the CASE 1 and CASE 2 scenario?

UPDATE

CASE 1 is solved by enclosing the security trimmed control around the <div id="s4-ribbonrow">

  • You can use EmitDiv in the SecurityTrimmedControl to make it not render a containing div, hence only whay you put inside of the control will be rendered – Robert Lindgren Apr 1 '14 at 7:14
  • How does emitdiv help? I tried setting it to true, also false, yet the div tag is still there – variable Apr 2 '14 at 5:03
0

Change it to: div id=”div1' style=”display:none”

now add following block

Sharepoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControl1″ runat=”server” PermissionsString=”AddAndCustomizePages” script type=”text/javascript” document.getElementById(“div1”).style.display = “block”; /script /Sharepoint:SPSecurityTrimmedControl

Please find more details http://subhasis07.wordpress.com/2011/06/13/spsecuritytrimmedcontrol-in-sharepoint-2010/

  • CASE 1 or CASE 2? – variable Apr 24 '14 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.