如何用Client OM获取页面上一个Content web part的内容
2017-02-24 11:20
369 查看
【解决方法】
From: http://stackoverflow.com/questions/11814829/how-to-read-webpart-content-using-sharepoint-client-om
According to Wictor Wilén, The Client Object Model is fairly limited when it comes to working with Web Parts. Basic operations such as adding and removing Web Parts can be done as well as changing some default properties of the Web Part (such as Title). There's no access to custom Web Part properties. There's no access to custom Web Part properties. There's no way to access the custom properties or methods on a Web Part. If you need to do this kind of customization with remote clients, you have to add your own remote API to SharePoint. For more details please click Here. To get the required details of the webpart I used a combination of both methods. First, I fetched the list of web part details using the following code: ClientContext ctx = new ClientContext("http://foo"); File home = ctx.Web.GetFileByServerRelativeUrl("/SitePages/Page.aspx"); var wpm = home.GetLimitedWebPartManager(PersonalizationScope.Shared); var query = wpm.WebParts.Include(wp => wp.Id, wp => wp.WebPart)); var webPartDefenitions = ctx.LoadQuery(query); ctx.ExecuteQuery(); Then called the GetWebPart2 method of Webpartpages web service to download the content: var client = new WebPartPagesWebService(); client.Url = siteRootAddress+"/_vti_bin/Webpartpages.asmx"; client.Credentials = credential; // webPartId is a property of WebPart Defenition from the above code var webPartXmlString = client.GetWebPart2(pageAddress, webPartId, Storage.Shared, SPWebServiceBehavior.Version3); var webPartNode = XElement.Parse(webPartXmlString); |
From: http://stackoverflow.com/questions/11814829/how-to-read-webpart-content-using-sharepoint-client-om
相关文章推荐
- ajax指定为post但是未设置content-type时如何获取提交的内容
- asp.net cs 后台如何获取前端页面控件的内容
- 如何获取一个AlertDialog中的EditText中输入的内容
- 如何获取一个AlertDialog中的EditText中输入的内容
- 在php中,如何将一个页面中的标签,替换为用户想输出的内容
- 如何使用Dexexpress插件,获取一个文本框中的内容
- java中的文件读取和文件写出:如何从一个文件中获取内容以及如何向一个文件中写入内容
- 如何在一个页面内点击一个按钮,然后在下方显示内容?
- JS——如何在跳转后获取前一个页面的元素
- HttpClient获取响应内容类型Content-Type
- 获取一个url的页面的内容
- WinForm开发浏览器,WebBrowser获取页面内容,如何解决中文乱码
- jsp页面中,如何获取输入的内容,保持在文本框中,不清空
- 利用HttpClient写的一个简单页面获取
- WinForm开发浏览器,WebBrowser获取页面内容,如何解决中文乱码
- WinForm开发浏览器,WebBrowser获取页面内容,如何解决中文乱码
- 在jsp页面如何获取Map里面某一个指定集合的值并循环打印
- 如何用正则表示式获得一个页面内容中所有图片地址
- NSIS ---使用nsDialogs创建自定义页面,并获取输入到控件中的内容保存到一个XML文档中
- 一个页面如何放多个百度编辑器 Ueditor 1.4.3?PHP如何获取Ueditor 的值?