简体   繁体   English

在未安装 SharePoint 的服务器上使用 Sharepoint GridViews

[英]Using Sharepoint GridViews on server without SharePoint installed

I have a web application that needs to pull data from a Sharepoint list and display it with the same "look and feel" as a sharepoint list, but on a different web site.我有一个 Web 应用程序需要从 Sharepoint 列表中提取数据,并以与 Sharepoint 列表相同的“外观”显示它,但在不同的网站上。

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spgridview.aspx http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.spgridview.aspx

The web application is not installed on a server with the SharePoint foundation. Web 应用程序安装在具有 SharePoint 基础的服务器上。 The sharepoint DLLs were naturally missing, but I have copied them from the server where SP is installed and added them to my project. sharepoint DLL 自然丢失了,但我已从安装 SP 的服务器复制它们并将它们添加到我的项目中。 The page compiles now, but it's throwing an exception which appears whenever I insert the SPGridView ASP element.该页面现在可以编译,但它会抛出一个异常,每当我插入 SPGridView ASP 元素时就会出现该异常。

The exception is: System.ArgumentException: Absolute path information is required.例外情况是:System.ArgumentException:需要绝对路径信息。

Stack trace:堆栈跟踪:

[ArgumentException: Absolute path information is required.]
   System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) +12658807
   System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +112
   Microsoft.SharePoint.Utilities.SPUtility.ComputeFileHash(String filePath) +470
   Microsoft.SharePoint.Utilities.SPUtility.MakeBrowserCacheSafeLayoutsUrl(String name, Boolean localizable) +487
   Microsoft.SharePoint.WebControls.ScriptLinkInfo.ToScriptUrl(Page page) +488
   Microsoft.SharePoint.WebControls.ScriptLinkInfo.ToScriptBlock(Page page) +24
   Microsoft.SharePoint.WebControls.ScriptLink.RegisterForControl(Control ctrl, Page page, String name, Boolean localizable, Boolean defer, Boolean loadAfterUI, String language) +1195
   Microsoft.SharePoint.WebControls.ScriptLink.Register(Page page, String name, Boolean localizable, Boolean defer, String language, String uiVersion) +38
   Microsoft.SharePoint.WebControls.ScriptLink.Register(String uiVersion, Page page, String name, Boolean localizable, Boolean defer) +59
   Microsoft.SharePoint.WebControls.ScriptLink.Register(Page page, String name, Boolean localizable) +30
   Microsoft.SharePoint.WebControls.SPGridView.OnLoad(EventArgs args) +86
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

If I remove the SPGridView ASP element, the page runs.如果我删除 SPGridView ASP 元素,页面就会运行。 Does anyone know how to get this to work?有谁知道如何让它工作? I know I can use the Client Object Model, but AFAIK it doesn't provide anything to show lists with the same appearance and functionality as in Sharepoint.我知道我可以使用客户端对象模型,但是 AFAIK 它没有提供任何东西来显示具有与 Sharepoint 中相同的外观和功能的列表。

The simplest way to phantom host SharePoint content on a web page (ie show SharePoint content on a page hosted on a non-SharePoint server) is the classic and trusty old IFrame.在网页上虚拟托管 SharePoint 内容(即在托管在非 SharePoint 服务器上的页面上显示 SharePoint 内容)的最简单方法是经典且可信赖的旧 IFrame。 Here's the steps:以下是步骤:

  1. Create a view for the source list that eliminates things like navigation, headers, footers and the like.为源列表创建一个视图,消除导航、页眉、页脚等内容。 You want it to be as close to just the list data as possible.您希望它尽可能接近列表数据。
  2. On the target page, drop in an IFrame and set the source of said IFrame to point to the view page you customized in #1 above.在目标页面上,放入一个 IFrame 并将所述 IFrame 的源设置为指向您在上面 #1 中自定义的视图页面。
  3. Ensure things like cross domain scripting etc. is white listed for the source site on the target site.确保跨域脚本等内容在目标站点上的源站点被列入白名单。 SharePoint uses a LOT of JavaScript, especially these days so if your target site blocks cross domain scripting it could ruin your day. SharePoint 使用了大量的 JavaScript,尤其是这些天,所以如果您的目标网站阻止跨域脚本,它可能会毁了您的一天。

That should do it.那应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM