Sharepoint 2010 Scrollbar not working problem when hiding ribbon

Symptoms:

When using SPSecurityTrimmedControl for hiding Sharepoint 2010 ribbon scrollbar is not working for users who denied to see ribbon.

Cause:
If you use SPSecurityTrimmedControl cover all divs that include the ribbon in masterpage , the page is not renders correctly. This is an incorrect programming situation .

Incorret usage:

<SharePoint:SPSecurityTrimmedControl ID="IncorrectUsage" runat="server" PermissionsString="ManageWeb">
<div id="s4-ribbonrow" style="display:none">
<div id="s4-ribboncont">
   <SharePoint:SPRibbon...
    Your ribbon
   </Sharepoint:SRibbon>
</div>
</div>
</SharePoint:SPSecurityTrimmedControl>

Resolution:
Use your SPSecurityTrimmedControl inside of divs which is already covers ribbon.

Correct:

<div id="s4-ribbonrow" style="display:none">
<div id="s4-ribboncont">
<SharePoint:SPSecurityTrimmedControl ID="CorrectUsage" runat="server" PermissionsString="ManageWeb">
   <SharePoint:SPRibbon...
    Your ribbon
   </Sharepoint:SRibbon>
</SharePoint:SPSecurityTrimmedControl></div> </div>

..

For hiding ribbon correctly you need to add extra scripting .

First to be sure jquery added your master page .

<script type="text/javascript" src="https://blog.bugrapostaci.com/_catalogs/scripts/jquery.js"></script>

And we add an extra SPSecurityTrimmedControl which contains javascript for showing ribbon to who have to see.

<SharePoint:SPSecurityTrimmedControl ID="st1" runat="server" PermissionsString="ManageWeb">
this text will be shown by only admins
<script type="text/javascript">
$(document).ready(function()
{
$('#s4-ribbonrow').show();
});
</script>
</SharePoint:SPSecurityTrimmedControl>

and adding an extra attribute to cover div for hiding ribbon

<div id="s4-ribbonrow" style="display: none;">

Dont forget to save your master page and publish it.

If you dont want to attend too much you can download and use this tool for this.

http://spribbonvisibility.codeplex.com/

Happy solutions …
Bye now.
.

Advertisements