Share via


Create and Use a SharePoint Feature Package

When you create a custom Web page containing the XmlFormView control, the .aspx page can belong only to the root site collection of the SharePoint server. To create a page under a non-root site collection, the custom Web page needs to be deployed as a SharePoint feature. A SharePoint feature requires two simple XML files and is deployed using the stsadm.exe command-line tool, which can be automated with a batch file.

Sample Feature.xml and Module.xml Files

The following is a sample Feature.xml file which is necessary for giving the feature a unique ID and pointing to the Module.xml file.

<?xml version="1.0"?>
<Feature Id="8C4DD0CB-5A94-44da-9B7F-E9ED49C2B2DC" Title="Custom Web page"
Description="This simple example feature adds an aspx page with a hosted
XmlFormView control" Version="1.0.0.0" Scope="Web"
xmlns="https://schemas.microsoft.com/sharepoint/">
<ElementManifests>
    <ElementManifest Location="Module.xml"/>
</ElementManifests>
</Feature>

The Module.xml file contains information about the page or pages that are part of the solution.

<?xml version="1.0"?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
    <module name="file" url="" path="">
        <file url="XmlFormViewPage.aspx" type="ghostable"> </file>
    </module>
</Elements>

Change the file url value to the name of your .aspx page, and then run the command lines as described in the following section. You can create a batch file and run these command lines sequentially.

Run the stsadm.exe Commands to Deploy and Activate the Feature

  1. Create a folder under the Features folder on your server machine, typically located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES.

  2. Add your custom .aspx page to this folder.

  3. Create the Feature.xml and Module.xml files based on the examples shown in the previous section, and add them to the same location.

Deploy the Feature to SharePoint

The command-line syntax to deploy a feature is:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin\stsadm -o installfeature –filename FeatureFolderName\Feature.xml

Activate the Feature on a SharePoint Site Collection

The command-line syntax to activate a feature is as follows:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin\stsadm -o activatefeature –filename FeatureFolderName\Feature.xml -url https://ServerName/Sitecollection

Replace ServerName and SiteCollection with the actual names of your SharePoint server and the site collection name to which the feature will be activated.

See Also

Concepts

Authoring Custom Web Pages That Contain the XmlFormView Control

Other Resources

Channel 9 Screencast: Creating and Deploying a Feature for Windows SharePoint Services V3