.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Hide Version History in SharePoint 2010

Posted By:Jean Paul       Posted Date: June 30, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article I would like to take you through a Real World Scenario. You wanted to hide the Version History menu item from the documents menu.

In this article I would like to take you through a Real World Scenario. You wanted to hide the Version Historymenu item from the documents menu.


I am working on original code of Matthew Yarlett for the original code. Thank You Matthew for making things easier.

HideAction won't work!

The typical HideAction way of hiding ribbon items won't work with context menu items as they are rendered through JavaScript.

JavaScript Approach

The Version History menu item is residing in the Edit Control Block group of menu items. These menu items are rendered through the core.js java script file. The file resides in the _layouts folder.

We need to visit the file to find the Version History text & sequence number. The sequence number determines the position of menu item in the edit control block.

The file can be located in folder:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS

Opening the core.js file & locating Version History text & use the L_Versions_Text variable to look ahead in file & locate the sequence number as 800.


JavaScript Code

Following is the JavaScript code which perform the hiding functionality.


<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(editEcbMenusEx, 'Core.js');
function editEcbMenusEx() {
try {
if (typeof ctx == "undefined") {
else {
var css = 'li[sequence="800"]{display:none;}';
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){ style.styleSheet.cssText = css; }
else { style.appendChild(document.createTextNode(css)); }
} catch (e) {

Please note that the script is executed after Core.js is loaded.

How to test the code?

For testing the code, you need to perform the following steps:

1. Create a HideHistory.js file with above content & upload to Site Assets library

2. Edit the library page & add a content editor web part

3. Point the web part to our HideHistory.js file


4. Refresh the page

5. See the Version History menu item is hidden now



Please note that the hiding takes place in all libraries & lists where the content editor is placed. You need to add if condition to check for list template OR list name for conditional hiding.

If you need to apply to all pages without using Content Editor web part, you can add the code to master page. Please visit this link on how to do it.




In this article we have explored the way to hide Version History menu item in libraries.

The source code is attached here with.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend