views:

54

answers:

2

I need to create a web part page to be used in a SharePoint collection site. Any ideas?

A: 

Start with this walk-through:

http://msdn.microsoft.com/en-us/library/ee231546(v=VS.100).aspx

A good overview of developing for SharePoint:

http://msdn.microsoft.com/en-us/library/ee231517(v=VS.100).aspx

Update:

My mistake. Have a look at this post, http://stackoverflow.com/questions/1627756/adding-web-page-to-blank-sharepoint-site-definition it is still relevant for SharePoint 2010. The main difference is that visual studio will take care of creating a number of the files for you (feature, etc). Start by adding a SharePoint 2010 module to your SharePoint project. Part of the module will be a Sample.txt file. Delete this file and add the WebPartPage.aspx from the post I mention. Next edit the elements.xml file to reflect an appropriate name for you module. Then ensure this module is included in one of your features and you should have a simple web part page available to you once the feature is activated

Joe Capka
He was actually talking about a "Web part page" not a "Web part"
Janis Veinbergs
Correct. I need to generate SharePoint web part pages from Visual Studio. Thanks!
David
A: 

I usually copy default.aspx from 12\TEMPLATE\SiteTemplates\sts into a custom Feature. I can then customize the page if I need different Web Part Zone configurations.

Feature.xml:

<?xml version="1.0" encoding="utf-8"?>
<Feature Id="A94D977C-1F3B-4488-9DD5-88E0A03506B0"
    Title="My Sample WebPart Page Feature"
    Description=""
    Scope="Web"
    DefaultResourceFile="core"    
    Hidden="TRUE"
    xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <ElementManifests>
        <ElementManifest Location="Modules.xml" />
        <ElementFile Location="Files/default.aspx" />
    </ElementManifests>
</Feature>

Modules.xml:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <Module Name="WebPartPage" Url="" Path="Files">
        <File Url="MyPage.aspx" Path="default.aspx">
            <View List="$Resources:core,lists_Folder;/MyList" BaseViewID="0" WebPartZoneID="Right" WebPartOrder="1"/>
        </File>
    </Module>
</Elements>
Rich Bennema