Miguel Isidoro

Blog sobre .NET, Sharepoint e tecnologia em geral.

My Links

Archives

Post Categories

Login

Blog Stats

Blogs Portugueses

Blogs Sharepoint

SharePoint 2007 - Exporting Web Parts

When web parts are deployed in a SharePoint Site Collection, they become available in the Web Part Gallery, so that they can be added to web part pages. The Web Part Gallery page shows the list of web parts installed in a Site Collection and each of the web part listed is represented by an xml file of .webpart extension that contains its definition. An example of a .webpart file is the following:

<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="MyNamespace.SharePoint.WebParts.MyCustomWebPart, MyNamespace.SharePoint.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5874548632a535ab" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string"> MyCustomWebPart </property>
</properties>
</data>
</webPart>
</webParts>

From the Web Part Gallery page, you can export (download) the web part definition into a file for later import or inclusion in a deployment package.

You can also enable the Export option from web part itself when included in a web part page (this option is disabled by default). To do that, you must include the following lines of codes into the OnLoad event of your web part:

protected override void OnLoad(EventArgs e)

{

base.OnLoad(e);

 

if (this.WebPartManager.DisplayMode != WebPartManager.BrowseDisplayMode)

this.ExportMode = WebPartExportMode.All;

}

By adding this code, you will enable the web part to be exported when the page is being edited. An "Export…" option will be added to the web part edit context menu.

posted on Sunday, November 18, 2007 11:17 AM

Feedback

No comments posted yet
Title  
Name  
Url
Box Code
Protected by FormShield
Comments