locked
Custom 'edit' and 'delete' buttons in dispform.aspx? RRS feed

  • Question

  • I'm completely customizing the dispform.aspx file for displaying items of a list. I'd like to skip the default FormToolBar completely, and directly add buttons for editing, deleting and configuring permissions that specific item. 

    Any advice on how to accomplish that?

    Thursday, June 17, 2010 12:19 PM

Answers

All replies

  • Hi,

    You can use custom list definition and defining your own form, or you can use SharePoint Designer to do that.
    For example using SharePoint Designer ,
    1. Open the List in SharePoint Designer
    2. Open the DispForm.aspx in the SPD and modify it.


    Best regards,

    Riwut Libinuko
    SharePoint Architect, Singapore
    Microsoft MVP | SharePoint Server | Singapore
    Blog : http://blog.libinuko.com
    Thursday, June 17, 2010 2:56 PM
  • That's exactly what I've done, but I have no idea on how to add the 'Edit item', 'Delete item' and 'Configure permissions' buttons. I could do it if I had the code. And if I add the default bar 'FormToolBar', I've got no idea on how to extract the buttons from it or edit it.
    Friday, June 18, 2010 6:25 AM
  • Hi,

    I think what you need is custom template for a form. Please follow, step-by-step here:

    http://msdn.microsoft.com/en-us/library/aa543922.aspx


    Best regards,

    Riwut Libinuko
    SharePoint Architect, Singapore
    Microsoft MVP | SharePoint Server | Singapore
    Blog : http://blog.libinuko.com
    • Marked as answer by Seven M Saturday, June 26, 2010 3:13 AM
    Friday, June 18, 2010 2:23 PM
  • This can be done with javascripts for ex: adding edit button to the dispform.aspx  can be done like this

    <script>
    function getURLParameters() { 
        var qString = {}; 
        var reg = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { 
        qString[key] = value; 
        }); 

        return qString; 
    }


    function editURL()
    {
    var id = getURLParameters()["ID"];
    var source = getURLParameters()["Source"];
    window.location.href ="http://yoursite/listname/editform.aspx?ID="+id+"&Source="+source;
    }
    </script>
    <input type="button" value="Edit" onclick="editURL();"/>

     

     

    Similarly you can play with the url for permissions page.

    The delete part can be done using SPServices thanks to Marc D Anderson.

     

    The setback with this is these buttons are hardcoded and will be visible for all users irrespective of their permission level.


    San
    • Edited by SanRang Friday, February 3, 2012 1:24 AM added more info
    Friday, February 3, 2012 1:15 AM