How to: Make a custom web part appear in the web part gallery (SP2007)

If you have a custom web part that does not appear in your web part gallery, the most probable cause is that you have not defined it in the module.xml file.

Remember that, once you have created a custom web part in VS, you will need to add/reference it in the module.xml file.

In your module.xml file there will be a section like the following:

<!–WEB PARTS–>
<Module Name=”WebParts” List=”113″ Url=”_catalogs/wp”>
<File Path=”Webparts\MyCustomWebpart.webpart” Url=”MyCustomWebpart.webpart” Type=”GhostableInLibrary”  >
<Property Name=”Group” Value=”NameOfWebPartGalleryGroupThatYouWantYourWebPartToAppearIn” />
</File>

</Module>

Also, make sure to use the correct declaration in your webpart metaData like so:

<webParts>
<webPart xmlns=”http://schemas.microsoft.com/WebPart/v3″>
<metaData>
<type name=”FullyQualifiedProjectNameSpace.MyWebpartName, FullyQualifiedProjectNameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=theSolutionsPublicKeyToken” />
<importErrorMessage>Cannot import MyWebpartName Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name=”Title” type=”string”>My Web Part Title</property>
<property name=”Description” type=”string”>My Web Part Description.</property>
<property name=”ChromeType” type=”chrometype”>None</property>
</properties>
</data>
</webPart>
</webParts>

NOTE: Make sure you use the correct PublicKeyToken.

Now, even if you get everything right, you might not be able to see your webpart in the correct group in the web part gallery. The reason for this may be that you had already deployed a similarly named web part as part of a previous solution. So, the old web part would appear in the old group, and the deployment of the new web part would fail.

You need to remove the old web part and re-activate your new feature so that the web part will appear in the correct place.

 

For more information on SharePoint 2007 deployment, click here.

MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

This site uses Akismet to reduce spam. Learn how your comment data is processed.