Create a SharePoint Web Part Site in Visual Studio?
I need to create a开发者_StackOverflow社区 web part page to be used in a SharePoint collection site. Any ideas?
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, 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
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/">
<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/">
<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>
精彩评论