Enable Export with Custom WebParts

In SharePoint 2010 when you create custom Web Parts, you may notice that your new baby is not able to be exported. What if you want to allow your users to export that bad boy? Well, out of the box, SP doesn’t have that option enabled with custom Web Parts.

Exports this webpart to your computer.
Export this webpart to your computer link missing by default.

There are tons of articles out there talking about how to do this. So ill keep it short.

  1. Build your Web Part like you normally do
  2. Ensure it deploys, activates, etc, etc, etc.
  3. Within the “CreateChildControls()” method, add the Enable Export function.

You can choose between All, None, and NonSensativeData.

protected override void CreateChildControls()
{
     //Allows the properties of the web part to be exportable.
     this.ExportMode = WebPartExportMode.All;
}

You also need to ensure that your web.config includes the following:

   <webparts  enableExport="true" />

Go ahead and deploy your solution and give the new export option a try.

References

Leave a Reply

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