July 10, 2012

How to hide “Commit” controls from Edit Ribbon Tab For Lists in SharePoint 2010

We have a requirement to hide the Commit Controls (i.e Save and Cancel) from display forms (i.e. DispForm.aspx, EditForm.aspx, and NewForm.aspx) in custom lists that we have created.


Solution 1: using code-behind

If your list forms have a code behind attached to them, you can hide the controls by placing the following code into your Page_Load method:

SPRibbon ribbon = SPRibbon.GetCurrent(page);
if (ribbon != null)

Solution 2: using CSS

In case you don’t like the first solution or your forms are not customized to the point where you got code-behind, you can add the following as a child of PlaceHolderAdditionalPageHead

<style type="text/css">
        display: none !important;

Solution 3: using JQuery

In case you don’t like any of the previous solutions, you can use JQuery, the cool thing about this solution is that it can be used for the out-of0the0box lists too (by placing the below script in a content editor webpart):

$('#Ribbon\\.ListForm\\.Edit\\.Commit').css('display', 'none');

Let me know if you need more details about any of the solutions.

No comments:

Post a Comment