.dwp和.webpart的区别

.dwp和.webpart是用来描述web part的代码信息的文件的两个版本.

它们两个的区别就在于.dwp是用于SharePoint V2中的, 而.webpart文件是用在SharePoint V3中的. 在文件的内部, schema也是不同的, 这种不同可以通过xmlns属性的版本号区别出来.

这是.dwp(for v2)的一个例子.

<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>

 

这是.webpart文件的一个例子, 有少许不同.

<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>

主要的区别就是所有的web part的属性在v3中都通过property元素和一个name属性来指定. v2中的任何元素都有element name.

 

你应该用哪一种呢? 应该是.webpart, 毕竟它是稍微新一点的v3. 然而, 使用v2也的确没有什么不对的地方, 尽管v2的这种格式将来可能会在新版本的SharePoint产品中移除掉. 事实上, 如果你看一眼web part gallery, 你会看到很多还在使用dwp的web part. 所以, 目前为止, 我们建议使用新版本的.webpart, 但是如果你更熟悉.dwp的话, 你也可以使用它的.

来源:

The difference between .dwp and .webpart

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/08/21/the-difference-between-dwp-and-webpart.aspx

原文地址:https://www.cnblogs.com/awpatp/p/1738678.html