.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

posted on   中道学友  阅读(1116)  评论(1编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律

导航

< 2010年5月 >
25 26 27 28 29 30 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

技术追求准确,态度积极向上

点击右上角即可分享
微信分享提示