Share via


How to: Create a Simple Feature

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This example steps you through the process of creating a custom action Feature that adds a button to the toolbar of the form for editing announcements items within the scope of a SharePoint site.

To add a button to a toolbar in a list item form

  1. Create a SimpleFormToolbarButton folder in Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES.

    Note

    When you create a folder within the Features directory through Windows Explorer by right-clicking a folder, pointing to New, and then clicking Folder, the new folder does not have inherited permissions. If you deploy a Feature in the folder, then some Windows SharePoint Services pages, such as for site settings or list views, throw an exception. You can fix this problem by right-clicking the new folder, click Properties, click Security, and then click Advanced. On the Permissions tab, select Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these with entries explicitly defined here. Click OK. You can also fix this problem by creating the new folder at the command prompt through the md command.

  2. In this folder, create a Feature.xml file with the following content, which uses the Feature element to register the Feature.

    <Feature Title="New Simple Form Toolbar Button"
      Scope="Web" 
      Id="GUID" 
      xmlns="http://schemas.microsoft.com/sharepoint/">
      <ElementManifests>
        <ElementManifest Location="Elements.xml" />
      </ElementManifests>
    </Feature>
    
  3. To replace the GUID placeholder in the previous Id attribute, generate a GUID by running guidgen.exe, located in Local_Drive:\Program Files\Microsoft Visual Studio 8\Common7\Tools.

  4. Create an Elements.xml file in the SimpleFormToolbarButton folder that points to an .aspx file, such as the following, which uses the CustomAction element to define the custom action.

    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction Title="Simple" 
        Sequence="10" 
        RegistrationType="List" 
        RegistrationId="104" 
        Location="EditFormToolbar" 
        Id="Simple Toolbar">
        <UrlAction Url="/_layouts/SampleUrl.aspx" /> 
      </CustomAction>
    </Elements>
    
  5. To test the sample feature, create a SampleUrl.aspx page such as the following that displays "Hello, world!" and place it in the TEMPLATE\LAYOUTS directory.

    <html>
    <head >
    <title>Sample Page</title>
    </head>
    <body>
    <p>Hello, world!</p>
    </body>
    </html>
    
  6. At a command prompt, type the following commands to install the Feature in the deployment, and then activate the Feature on a specified subsite.

       a. stsadm -o installfeature -filename SimpleFormToolbarButton\Feature.xml
       b. stsadm -o activatefeature -filename SimpleFormToolbarButton\Feature.xml -url http://Server/Site/Subsite
    
  7. To try out the new button, navigate to the form for editing an existing announcements item.

See Also

Reference

Feature Element (Feature)

CustomAction Element (Custom Action)

Concepts

Working with Features

Custom Action

Custom Action Definitions

How to: Add Actions to the User Interface