How do you deploy a webpart within a feature?
i have my webpart as MyWebPart.cs file.
ive got got a feature which is used for something else. im just wondering if i can deploy this webpart along with the feature.
How do you deploy a webpart within a feature?
i have my webpart as MyWebPart.cs file.
ive got got a feature which is used for something else. im just wondering if i can deploy this webpart along with the feature.
The easiest way I've found is to use a tool such as WSPBuilder. This integrates with Visual Studio and allows you to create a new web part with feature.
Try this out and incorporate the existing code and feature you've already written. I guarantee it will save you a lot of time compared to doing everything manually.
VSeWSS may also do the job but I've never found it as easy to use.
So I guess you need help with deploying a webpart through a feature. Here´s how to do that.
In your elements.xml file (in the feature) add a module, like:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="WebParts" List="113" Url="_catalogs/wp" Path="DWP">
<File Url="MyWebpart.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="MyWebPartGroup"></Property>
</File>
</Module>
</Elements>
The Path (DWP) is a folder in the feature where the actual .webpart file is stored and it can look like this:
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Full class name, Full 4-part assembly name" />
<importErrorMessage>Import error message</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">My webpart</property>
<property name="Description" type="string">Description of WP</property>
</properties>
</data>
</webPart>
</webParts>
Using wsp builder to package this into a wsp makes things with safecontrols and DLL deployment etc so much easier so use that...