Wednesday, 16 May 2012

Hide the SharePoint ribbon from anonymous users and in SharePoint List display page


 


For hide the SharePoint ribbon from anonymous users we can use below STYLE in masterpage 
AnonymousTemplate.
  
<style type="text/css">
body #s4-ribbonrow {
display: none;
}
</style> 
 
Example 1: 
 
<asp:LoginView id="LoginView2" runat="server" >
<AnonymousTemplate>
<div class="customLogin"> 
<a href="/_layouts/authenticate.aspx"><span class="style3">Login</span></a>
</div>  
<style type="text/css">
body #s4-ribbonrow {
display: none;
}
</style>
</AnonymousTemplate>
<LoggedInTemplate> 
<style type="text/css">
.customLogin {
display: none;
}
</style>
</LoggedInTemplate>
</asp:LoginView>
 
 
and sometimes SharePoint lists may have a workflows for update and insert the items, so this time Ribbon features will visible to users like edit, new item, delete like that.
User should have update skills through workflow but he should not have editable features in ribbon. So you will have to remove/hide the ribbon for user view.
 
 
In order to completely hide the ribbon either add Content Editor Web part and you can add the below script in Content Editor Web part html source
I don’t want to display the ribbon in list item display page, so i have added CEWP in DispForm.aspx page and added below script in it.

<script type="text/javascript">
        document.getElementById("s4-ribbonrow").style.display = "none";
    </script>

No comments:

Post a Comment