2

I am trying to access data remotely from sharepoint 2010 site using client object model. For some restrictions I am not able to use CAML query even if I use I am not able to filter for proper audiences based on user login (if you can help me regarding the CAML query is also fine :: i do not know how to get current user audience name and all audiences using CAML/client object model. This code sits on the mobile site and calling the share point site as shown in my code). This following code works good but not able to get the content from the webpart. Can someone help regarding this.

    using (ClientContext ctx = new ClientContext("https://mysite.com/Pages/Default.aspx"))
      {
                 ctx.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>   (clientContext_ExecutingWebRequest);    

                 File home=ctx.Web.GetFileByServerRelativeUrl("/Student/Pages/default.aspx");                      
             //get the web part manager
                     Microsoft.SharePoint.Client.WebParts.LimitedWebPartManager wpm = home.GetLimitedWebPartManager(Microsoft.SharePoint.Client.WebParts.PersonalizationScope.Shared);

                IEnumerable<Microsoft.SharePoint.Client.WebParts.WebPartDefinition> wpds = null;
             //create the LINQ query to get the web parts from
             //the web part definition collection
                wpds = ctx.LoadQuery(wpm.WebParts.Include(wp => wp.Id,wp => wp.WebPart)); 
             //load the list of web parts
                ctx.ExecuteQuery();
             //enumerate the results
                foreach (Microsoft.SharePoint.Client.WebParts.WebPartDefinition wpd in wpds)
                {
                   string title=  wpd.WebPart.Title;
                   Microsoft.SharePoint.Client.WebParts.WebPart wpart = wpd.WebPart;     

                  ????? How to render and receive the data (looking for the same data When you browse the site with the browser)      
                }

              Code continues...
Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • From what i can read about the API what you are trying to do (if i understand you correctly) is not possible. If you read here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.webparts.webpart.aspx you can see that they state the client context version of the webpart is for adding, and deleting webparts. It contains no methods to access the webpart render or data. – sjkp Jan 09 '13 at 18:51

1 Answers1

0

I am also struggling with this issue. It really looks like this is not possible with client object model. Actually i've asked it to some SharePoint staff member at Build Conference 2012.

But, with the SharePoint Designer it's actually possible to download the wanted WebPart. Fiddler may come handy to track down which service will deliver you the bits.

Take a look at this post here on SharePoint StackExchange

Unfortunately the post will not give you any concrete way to solve it.

Wish you good luck!

Community
  • 1
  • 1
kaiser
  • 53
  • 1
  • 6
  • if your answer is not correct then comment below the question dont answer. – Parvathy Feb 08 '13 at 11:32
  • I did wanted firstly to comment. But i can not see the "add comment" button below his post. But actually this approach will work. Just details are not given. – kaiser Feb 08 '13 at 12:42
  • itz ok no problem. i just told if it is not correct then don't post. – Parvathy Feb 08 '13 at 12:45