Thursday, March 17, 2011

Deploy a web part using feature

Create a normal cs file for the web part. To deploy it, create 2 files in the feature folder - Feature.xml, elements.xml and webpart.webpart

wpchat.webpart---------------------------------------

webParts
webPart xmlns="http://schemas.microsoft.com/WebPart/v3"
metaData
type name="Eversheds.InstantMessaging.WebParts.WPChat, Eversheds.InstantMessaging, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b0c7276684f0a390 "/type
importErrorMessageCan not import WPChat/importErrorMessage
/metaData
data
properties
property name="Title" type="string"IT Service Desk/property
property name="Description" type="string"A web part which allows the user to chat /property
property name="MissingAssembly" type="string"Cannot import this Web Part./property
property name="DisplayName" type="string"IT Service Deskproperty
property name="Name" type="string"ITServiceDesk/property
property name="AllowHide" type="bool"False/property
property name="AllowClose" type="bool"False/property
property name="ChromeType" type="chrometype"None/property
property name="AllowZoneChange" type="bool"True/property
property name="Hidden" type="bool"False/property
property name="AllowMinimize" type="bool"False/property
property name="AllowEdit" type="bool"True/property
/properties
/data
/webPart
/webParts

Feature.xml ---------------

?xml version="1.0" encoding="utf-8"?
Feature Id="D34D00B1-EC5C-4da8-8C50-009CB4B8BB42"
Title="IMCHATFEATURE"
Description="This is the chat Webpart"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Site"
ReceiverAssembly="Eversheds.InstantMessaging, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=b0c7276684f0a390 "
ReceiverClass="Eversheds.InstantMessaging.FeatureReceiver.ReceiverChatFeature"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/"
ElementManifests
ElementManifest Location="elements.xml"/
ElementFile Location="WPChat.webpart" /
/ElementManifests
/Feature


Element.xml--------------------

?xml version="1.0" encoding="utf-8" ?
Elements xmlns="http://schemas.microsoft.com/sharepoint/"
Module Name="WebPartPopulation" Url="_catalogs/wp" RootWebOnly="TRUE" List="113"
File Url="WPChat.webpart" Type="GhostableInLibrary"
/File
/Module
/Elements

Deploy this using wsp and the web part can be added to the web part gallery.

1 comment:

  1. Hi Swati,

    That was nice but can you please explain step wise what you are doing and why.

    Thanks,

    ReplyDelete