将 Web 部件从 SharePoint Designer 2010 移至 Visual Studio 2010?
我在 SharePoint Designer 2010 中开发了一个数据表单 Web 部件。该 Web 部件提供列表的筛选视图以及编辑和插入功能。我想将代码移至 Visual Studio 中,成为我所有 SP 增强功能的解决方案。
我将 Web 部件从 SP Designer 导出到 .webpart 文件,并将其用作可视化 Web 部件项目中的 .webpart,但是当我部署该项目时,Visual Studio 中的 Web 部件中没有任何数据。从 SP Designer 部署的同一 Web 部件确实包含数据。
我尝试更改 VS Web 部件 .cs 类以从 Microsoft.SharePoint.WebPartPages.DataFormWebPart 继承,但这并没有解决问题。这是 .webpart 文件,感谢任何帮助:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="PipelineItemEditor.VisualWebPart1.VisualWebPart1, $SharePoint.Project.AssemblyFullName$" />
<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
</metaData>
<data>
<properties>
<property name="InitialAsyncDataFetch" type="bool">False</property>
<property name="ChromeType" type="chrometype">TitleOnly</property>
<property name="Title" type="string">My Pipeline Items</property>
<property name="Height" type="string" />
<property name="CacheXslStorage" type="bool">True</property>
<property name="ListDisplayName" type="string" null="true" />
<property name="AllowZoneChange" type="bool">False</property>
<property name="AllowEdit" type="bool">False</property>
<property name="XmlDefinitionLink" type="string" />
<property name="DataFields" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="ListName" type="string" null="true" />
<property name="NoDefaultStyle" type="string">TRUE</property>
<property name="AutoRefresh" type="bool">True</property>
<property name="ViewFlag" type="string">8388621</property>
<property name="Direction" type="direction">NotSet</property>
<property name="AutoRefreshInterval" type="int">60</property>
<property name="AllowConnect" type="bool">False</property>
<property name="Description" type="string" />
<property name="AllowClose" type="bool">False</property>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="ParameterBindings" type="string">
<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)"/>
<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)"/>
<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)"/>
<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)"/>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/>
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)"/>
<ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)"/>
<ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)"/>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
</property>
<property name="Xsl" type="string" null="true" />
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="ListUrl" type="string">Lists/Pipeline</property>
<property name="DataSourceID" type="string" />
<property name="FireInitialRow" type="bool">True</property>
<property name="ManualRefresh" type="bool">False</property>
<property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowHide" type="bool">False</property>
<property name="PageSize" type="int">-1</property>
<property name="SampleData" type="string" null="true" />
<property name="BaseXsltHashKey" type="string" null="true" />
<property name="AsyncRefresh" type="bool">True</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
<property name="AllowMinimize" type="bool">False</property>
<property name="TitleUrl" type="string">/Lists/Pipeline</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="DataSourcesString" type="string" />
<property name="GhostedXslLink" type="string">main.xsl</property>
<property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
<property name="DisplayName" type="string">All Pipeline Items</property>
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="Width" type="string" />
<property name="ExportMode" type="exportmode">All</property>
<property name="XslLink" type="string" null="true" />
<property name="ViewContentTypeId" type="string">0x</property>
<property name="HelpUrl" type="string" />
<property name="XmlDefinition" type="string">
<View Name="{2F369D62-EFD0-4E6F-961D-BA71E4622076}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="All Pipeline Items" Url="/SitePages/pipelinetest.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png">
<Query>
<Where>
<Eq>
<FieldRef Name="Author"/>
<Value Type="Integer">
<UserID/>
</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="Created_x0020_Date" Ascending="FALSE"/>
</OrderBy>
<GroupBy>
</GroupBy>
</Query>
<ViewFields>
<FieldRef Name="Edit"/>
<FieldRef Name="PItemType"/>
<FieldRef Name="PItemText"/>
<FieldRef Name="PItemLink"/>
<FieldRef Name="PItemDirection"/>
<FieldRef Name="PItemPicture"/>
<FieldRef Name="Created"/>
<FieldRef Name="Related_x0020_Tags"/>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard"/>
<ViewStyle ID="17"/>
</View>
</property>
<property name="Default" type="string">FALSE</property>
<property name="TitleIconImageUrl" type="string" />
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="SelectParameters" type="string" />
</properties>
</data>
</webPart>
</webParts>
I've developed a data form web part in SharePoint Designer 2010. The web part present a filtered view of a list along with edit and insert functions. I want to move the code out to Visual Studio into a solution I have for all our SP enhancements.
I exported the web part to a .webpart file from SP Designer and used that as the .webpart in a visual web part project, but when I deploy the project, the web part from Visual Studio doesn't have any data in it. The same web part deployed from SP Designer does have data in it.
I tried changing the VS web part .cs class to inherit from Microsoft.SharePoint.WebPartPages.DataFormWebPart, but that didn't fix the problem. Here's the .webpart file, any help is appreciated:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="PipelineItemEditor.VisualWebPart1.VisualWebPart1, $SharePoint.Project.AssemblyFullName$" />
<importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
</metaData>
<data>
<properties>
<property name="InitialAsyncDataFetch" type="bool">False</property>
<property name="ChromeType" type="chrometype">TitleOnly</property>
<property name="Title" type="string">My Pipeline Items</property>
<property name="Height" type="string" />
<property name="CacheXslStorage" type="bool">True</property>
<property name="ListDisplayName" type="string" null="true" />
<property name="AllowZoneChange" type="bool">False</property>
<property name="AllowEdit" type="bool">False</property>
<property name="XmlDefinitionLink" type="string" />
<property name="DataFields" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="ListName" type="string" null="true" />
<property name="NoDefaultStyle" type="string">TRUE</property>
<property name="AutoRefresh" type="bool">True</property>
<property name="ViewFlag" type="string">8388621</property>
<property name="Direction" type="direction">NotSet</property>
<property name="AutoRefreshInterval" type="int">60</property>
<property name="AllowConnect" type="bool">False</property>
<property name="Description" type="string" />
<property name="AllowClose" type="bool">False</property>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="ParameterBindings" type="string">
<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)"/>
<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)"/>
<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)"/>
<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)"/>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/>
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)"/>
<ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)"/>
<ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)"/>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
</property>
<property name="Xsl" type="string" null="true" />
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="WebId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="ListUrl" type="string">Lists/Pipeline</property>
<property name="DataSourceID" type="string" />
<property name="FireInitialRow" type="bool">True</property>
<property name="ManualRefresh" type="bool">False</property>
<property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Mobile</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="AllowHide" type="bool">False</property>
<property name="PageSize" type="int">-1</property>
<property name="SampleData" type="string" null="true" />
<property name="BaseXsltHashKey" type="string" null="true" />
<property name="AsyncRefresh" type="bool">True</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="ListId" type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
<property name="AllowMinimize" type="bool">False</property>
<property name="TitleUrl" type="string">/Lists/Pipeline</property>
<property name="CatalogIconImageUrl" type="string" />
<property name="DataSourcesString" type="string" />
<property name="GhostedXslLink" type="string">main.xsl</property>
<property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
<property name="DisplayName" type="string">All Pipeline Items</property>
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="Width" type="string" />
<property name="ExportMode" type="exportmode">All</property>
<property name="XslLink" type="string" null="true" />
<property name="ViewContentTypeId" type="string">0x</property>
<property name="HelpUrl" type="string" />
<property name="XmlDefinition" type="string">
<View Name="{2F369D62-EFD0-4E6F-961D-BA71E4622076}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="All Pipeline Items" Url="/SitePages/pipelinetest.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png">
<Query>
<Where>
<Eq>
<FieldRef Name="Author"/>
<Value Type="Integer">
<UserID/>
</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name="Created_x0020_Date" Ascending="FALSE"/>
</OrderBy>
<GroupBy>
</GroupBy>
</Query>
<ViewFields>
<FieldRef Name="Edit"/>
<FieldRef Name="PItemType"/>
<FieldRef Name="PItemText"/>
<FieldRef Name="PItemLink"/>
<FieldRef Name="PItemDirection"/>
<FieldRef Name="PItemPicture"/>
<FieldRef Name="Created"/>
<FieldRef Name="Related_x0020_Tags"/>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard"/>
<ViewStyle ID="17"/>
</View>
</property>
<property name="Default" type="string">FALSE</property>
<property name="TitleIconImageUrl" type="string" />
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="SelectParameters" type="string" />
</properties>
</data>
</webPart>
</webParts>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 https://sharepoint.stackexchange .com/questions/24932/moving-web-part-out-of-sharepoint-designer-2010-to-visual-studio-2010/ 在避免http://imgs.xkcd.com/comics/wisdom_of_the_ancients.png的兴趣
在空 SharePoint 项目中创建新的 Web 部件项。
将导出的 Web 部件复制到 .webpart 文件中
删除 .cs 文件
编辑 elements.xml 文件以设置新 Web 部件的显示名称等
部署解决方案
从库加载您的 DFWP Web 部件版本。
在这种情况下,您不需要创建新类,只需使用 .webpart 文件中设置的预设配置创建现有 Webpart 的模板实例
Cross posting answer from https://sharepoint.stackexchange.com/questions/24932/moving-web-part-out-of-sharepoint-designer-2010-to-visual-studio-2010/ in the interests of avoiding http://imgs.xkcd.com/comics/wisdom_of_the_ancients.png
Create a new webpart item in an empty SharePoint project.
Copy your exported webpart into the .webpart file
Remove the .cs file
Edit the elements.xml file to set the display name and such for your new web part
Deploy the solution
Load your version of the DFWP web part from the gallery.
In this case you don't need to create a new class, you're just creating a template instance of an existing webpart with pre-set configuration which is set in the .webpart file