Thursday, August 9, 2012

SharePoint 2010 Webpart page not showing Quick Launch

Some times SharePoint 2010 site newly created webpart page, publishing page does not show Quick launch bar(Left navigation panel) on page. It might be hide by some css available on page or some content place holder override by master page.

To solve the above issue, follow the following steps:-
1) Open your site in sharepoint designer.
2) Open your webpart page in advanced mode.
3) Remove the below content place holder.
   
<asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server">
</asp:Content>
 
4)Save the page, it will show the Quick launch bar on page. If it is not showing on page, then remove the below CSS available on page:-
 
<style type="text/css">
body #s4-leftpanel {
    display:none;
}
.s4-ca {
    margin-left:0px;
}
</style>

5) Save the page, quick launch bar appear on page.

Thursday, March 8, 2012

Disabled print option for SharePoint page


If you want to prevent user from printing SharePoint site page, you can use the below script in CEWB on your SharePoint site.


//Disabled File print and ctrl + P
<style type="text/css" media="print">
body { visibility: hidden; display: none }
</style>

The above JavaScript is not totally disabled the CTRL + P or Print option from browser File option. It tells the browser that if this Web page is set to print, switches the body to display nothing. Then, all that will print will be the standard header and/or footer that the browser appends to printed pages.  The user always get printed page with heading and blank page.

Disabled Right click, CTRL + A, C, V using JavaScript in SharePoint


You want user to avoid copy, Paste data from SharePoint site, use the below script in CEWB. It will prevent user to right click, and Copy, Paste data from SharePoint page

<script type="text/javascript">
    var message="Sorry, you do not have permission to right click.";

    function clickIE4(){
    if (event.button==2){
        alert(message);
        return false;
        }
    }

    function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){
            if (e.which==2||e.which==3){
                alert(message);
                return false;
                }
            }
        }
        if (document.layers){
            document.captureEvents(Event.MOUSEDOWN);
            document.onmousedown=clickNS4;
            }
        else if (document.all&&!document.getElementById){
            document.onmousedown=clickIE4;
        }
        document.oncontextmenu=new Function("alert(message);return false")
</script>

<script language="JavaScript1.2">

function disableselect(e){
return false
}

function reEnable(){
return true
}

//if IE4+
document.onselectstart=new Function ("return false")

//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>

Auto Log Off after 10 min in SharePoint site


Some time users are required auto log off the SharePoint site after particular time for security. Here is JavaScript to add in CEWB on page.

You can set time in JavaScript and called the default Sign Out page of SharePoint. If you want to set auto log off for one particular page, set the below JavaScript function in CEWB on that page, otherwise for whole SharePoint site add the JavaScript function on master page.

<script type="text/javascript">
//Added for Auto LogOFF after 10 min


    function Timeout(){
        var t = setTimeout("RedirectToLogout()", 10*60000);
    }
    function RedirectToLogout(){
       var path = "http://YouSite/_layouts/SignOut.aspx";
       window.navigate(path);
    }
    </script>
<script>
  window.onload=Timeout;
</script>


Happy Coding