in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2010, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Corey Roth - DotNetMafia.com - Tip of the Day

Bringing you the latest time saving tips for SharePoint 2010, MOSS 2007, ASP.NET, LINQ, and Visual Studio 2010

The difference between .dwp and .webpart

I have been doing some quite a bit of mentoring to new SharePoint developers lately and was asked the question of what the difference was between a .dwp and .webpart file and which one should be used.  Yes, I know this is an intro topic but if you are new to SharePoint you aren't going to know this.  As you may know, they are both files used for describing where the code is for a web part.  The difference is .dwp was the file extension used in version 2 of SharePoint and .webpart is a new extension used in version 3.  Inside the files, the schemas are different and it is indicated as such by the version number on the xmlns attribute.

Here is an example of a version 2 schema.

<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">

  <Assembly>Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>

  <TypeName>Microsoft.SharePoint.Portal.WebControls.SearchBoxEx</TypeName>

  <Title>Search Box</Title>

  <Description>Used to search document and items.</Description>

  <FrameType>None</FrameType>

  <AllowMinimize>true</AllowMinimize>

  <AllowRemove>true</AllowRemove>

  <IsVisible>true</IsVisible>

  <Width>335px</Width>

  <GoImageUrl xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/gosearch.gif</GoImageUrl>

  <GoImageUrlRTL  xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/goRTL.gif</GoImageUrlRTL>

  <GoImageActiveUrl xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/gosearch.gif</GoImageActiveUrl>

  <GoImageActiveUrlRTL  xmlns="urn:schemas-microsoft-com:SearchBoxEx">/_layouts/images/goRTL.gif</GoImageActiveUrlRTL>

</WebPart>

Version 3 is a little different.

<webParts>

  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">

    <metaData>

      <type name="Microsoft.SharePoint.Portal.WebControls.BusinessDataListWebPart, Microsoft.SharePoint.Portal,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />

      <importErrorMessage>Cannot import this web part.</importErrorMessage>

    </metaData>

    <data>

      <properties>

        <property name="Title" type="string">Business Data List</property>

        <property name="Description" type="string">Display a list of items from a data source in the Business Data Catalog.</property>

        <property name="CatalogIconImageUrl" type="string">/_layouts/images/bizdatawebpart.gif</property>

        <property name="CacheXslStorage" type="bool">true</property>

        <property name="CacheXslTimeOut" type="int">600</property>

      </properties>

    </data>

  </webPart>

</webParts>

The main difference is that all properties passed to the web part are specified with a property element and a name attribute in version 3.  Version 2 uses different element names for everything. 

Which file extension should you be using?  Probably .webpart since it is version 3.  However, there is really nothing wrong with using version 2 although maybe it will be removed from a future version of SharePoint.  If you take a look at the web part gallery, you will see plenty of web parts still using .dwp.  So for now, I recommend version .webpart, but if you are more familiar with the syntax of version .dwp, have at it.

Published Aug 21 2008, 04:50 PM by CoreyRoth
Filed under:

Comments

 

YESChandana -Blog said:

My favorite links from the 4th week of August 2008

August 24, 2008 6:48 AM
 

Provision a WebPart using a SharePoint Feature. « More Soma Please… said:

Pingback from  Provision a WebPart using a SharePoint Feature. &laquo; More Soma Please&#8230;

August 4, 2009 5:04 AM
 

Preet said:

Hi,

I don't know your (Author's) name. But whomsoever you are. You had done amazing job. I am .Net Developer and using sharepoint since while but your articles are so nicely written that any new developer will find it very comfortable. Once again hats off to you and thanks for writting such wonderful articles. Keep up the good work.

Thanks,

Preet

February 16, 2010 10:11 PM
 

Himani said:

Thanks. This is the information I was searching for. I ahvea n additional out of place query though. The .dwp or .webpart files that are provisioned using a WSP, go to which location within the filesystem?

February 24, 2010 3:44 AM
 

CoreyRoth said:

They go into the web part gallery inside SharePoint.  You won't actually find them on the file system anywhere.

February 24, 2010 8:54 AM
 

Dean said:

I put a ContentEditor web part on a page. Added text for a disclaimer statement. I exported the web part as disclaimer.dwp. I imported it into the web part gallery and added it to a page. Worked great. Now I want to add it to a site definition. Nothing I try works. HELP!!

March 8, 2010 11:38 AM
 

CoreyRoth said:

If you want to add it to a site definition, I recommend putting it in a feature and then use feature stapling to attach that feature to your site definition.

March 8, 2010 11:43 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is a SharePoint Consultant for Stonebridge, Inc. specializing in clients in the Energy Sector.
2009 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems