Using Sharepoint GridViews on server without SharePoint installed

620 views Asked by At

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.

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. The sharepoint DLLs were naturally missing, but I have copied them from the server where SP is installed and added them to my project. The page compiles now, but it's throwing an exception which appears whenever I insert the SPGridView ASP element.

The exception is: System.ArgumentException: Absolute path information is required.

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

1

There are 1 answers

0
Cornelius J. van Dyk On

The simplest way to phantom host SharePoint content on a web page (i.e. show SharePoint content on a page hosted on a non-SharePoint server) is the classic and trusty old 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.
  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.

That should do it.