Tuesday, August 30, 2011

Sharepoint 2010 Deploy visual web part to "MBD Web Parts" instead of "Custom".

Goal
To deploy our custom visual webpart to a custom group name "MBD Web Parts" instead of getting deployed to "Custom". Please follow below given steps to see how to reproduce.

  • Open Visual Studio 2010.

  • File > New > Sharepoint > Visual Web Part > Name it "Sample"

  • Delete the "VisualWebPart1"(Default) and add a new Visual Web Part file "DemoWebPart".

  • Complete writing code.

  • Right click project and deploy.

  • Visit your website.

  • Site Actions > Edit Site

  • Click "Add a Web Part". On the top ribbon.


This will show up our web part in the Group name "Custom", but we need to the web part in a group name "MBD Web Parts".

Simple Solution


  • Expand "DemoWebPart" and open "Element.xml".

  • Modify an attribute value in the xml from "Custom" to "MBD Web Parts".

  • Right click project and deploy.

  • Visit your website.

  • Site Actions > Edit Site

  • Click "Add a Web Part". On the top ribbon.


You should now be able to see our custom category of "MBD Web Parts" and not in "Custom".

Change in Element.xml


<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="DemoWebPart" List="113" Url="_catalogs/wp" RootWebOnly="TRUE">
<File Path="DemoWebPart\DemoWebPart.webpart" Url="DemoWebPart.webpart" Type="GhostableInLibrary" >
<Property Name="Group" Value="MBD Web Parts" />
</File>
</Module>
</Elements>



Hope this is helpfull for you!

No comments:

Post a Comment