none
How to hide the "New Item" link which is present the Dispform.aspx of a List Item

    Question

  • How to hide the "New Item" link which is present the Dispform.aspx of a List Item.  
     
    Is it possible using Share point designer? if yes then please tell the process.
    Thanks in advance.
    • Edited by Rajendra Kumar Iyga Friday, October 3, 2008 8:39 AM
    • Moved by Mike Walsh FIN Friday, October 3, 2008 10:52 AM wrong forum (Moved from SharePoint - Development and Programming to SharePoint - Design and Customization)
    Friday, October 3, 2008 8:38 AM

Answers

  • One way is to make custom dispform.aspx and remove standard toolbar (and lose some other functions too :( )
    Start from here: http://sharepointbergen.blogspot.com/2007/04/creating-custom-forms-for-sharepoint.html

    Or you can add some Javascript on page (inside PlaceHolderMain):
    <script language="javascript" type="text/javascript">
    _spBodyOnLoadFunctionNames.push("hideButton"); //this will execute hideButton function after loading

    function hideButton() {
        document.getElementById('IDofButton').style.display=“none”;
    }

    </script>


    You can find IDofButton by looking at HTML source of Dispform.aspx (or you can use IE Developer toolbar)


    Sunday, October 5, 2008 9:36 PM

All replies

  • SPD questions go to Design/Customization.

    This Programming forum is typically for programming using Visual Studio and other strictly programming issues (creating web parts; using web services; writing event handlers etc.)

    Moving to the Design/Customization forum 


    Friday, October 3, 2008 10:52 AM
  • One way is to make custom dispform.aspx and remove standard toolbar (and lose some other functions too :( )
    Start from here: http://sharepointbergen.blogspot.com/2007/04/creating-custom-forms-for-sharepoint.html

    Or you can add some Javascript on page (inside PlaceHolderMain):
    <script language="javascript" type="text/javascript">
    _spBodyOnLoadFunctionNames.push("hideButton"); //this will execute hideButton function after loading

    function hideButton() {
        document.getElementById('IDofButton').style.display=“none”;
    }

    </script>


    You can find IDofButton by looking at HTML source of Dispform.aspx (or you can use IE Developer toolbar)


    Sunday, October 5, 2008 9:36 PM
  • The easiest way to do that is by means of JavaScript

    Use the following function :

     

    hideFormMenuItems("New Item","Alert Me");  
       
    function hideFormMenuItems()  
    {    
        var titleToHide="";  
        var anchorTag;  
        var allAnchorTags = document.getElementsByTagName('a');  
        for(var i = 0; i < hideFormMenuItems.arguments.length; i++ )  
        {   
            titleToHide = hideFormMenuItems.arguments[i];  
            if(titleToHide!='Alert Me')  
            {  
                for (var j = 0; j < allAnchorTags.length; j++)  
                {  
                    anchorTag= allAnchorTags[j];      
     
                    if (anchorTag.title.indexOf(titleToHide)!=-1)  
                    {  
                        anchorTag.parentNode.parentNode.parentNode.parentNode.  
                        parentNode.style.display="none";  
                        anchorTag.parentNode.parentNode.parentNode.parentNode.  
                        parentNode.nextSibling.style.display="none";  
                        break;  
                    }  
                }  
            }  
            else 
            {  
                for (var k=0; k < allAnchorTags.length;k++)  
                {  
                    anchorTag= allAnchorTags[k];  
                    if (anchorTag.id.indexOf("SubscribeButton")!=-1)  
                    {    
                        anchorTag.parentNode.parentNode.parentNode.parentNode.  
                        parentNode.style.display="none";  
                        break;  
                    }  
                }   
            }  
        }  
     
        var allSpanTags = document.getElementsByTagName("span");  
        var spanTag;  
        var toolbarRow;  
        var lastCell;  
     
        for(var m=0; m < allSpanTags.length;m++)  
        {  
            spanTag = allSpanTags[m];  
          
        if(spanTag.id=='part1')  
        {  
            toolbarRow = spanTag.childNodes[2].firstChild.firstChild;  
            lastCell = toolbarRow.lastChild.previousSibling;  
            while(lastCell.style.display=='none')  
            {  
                lastCell = lastCell.previousSibling;  
            }  
            if(lastCell.innerText == '|')  
            {  
                lastCell.style.display='none';  
                break;  
            }  
        }  

     

     

    fore more info : http://www.codeproject.com/KB/sharepoint/sharepoint-customization2.aspx


    Ayman M. El-Hattab, Microsoft Certified SharePoint Specialist, http://ayman-elhattab.blogspot.com
    Friday, January 30, 2009 12:29 PM