The difference between .dwp and .webpart
Posted
Thursday, August 21, 2008 4:50 PM
by
CoreyRoth
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.