Friday
Jul162010
SharePoint ClientContext.List is missing?
Friday, July 16, 2010 at 9:19AM The SharePoint Object Model has:
- SPContext Members
- SPContext.Current (static)
- SPContext.Site
- SPContext.Web
- SPContext.List
By comparison, the SharePoint Client Object Model only has:
- ClientContext Members
- ClientContext.Current (static)
- ClientContext.Site
- ClientContext.Web
- ClientContext.List (AWOL missing!)
Here's one trick I've started using - the current list exists on the page in javascript (ctx.listName)
So using Silverlight's Javascript bridge I'm able to test and pull that value back into Silverlight - without any looping through the ClientContext.Web.Lists.
string listName = string.Format("{0}", HtmlPage.Window.Eval("ctx.listName")); // using string.Format to take care of null problems // the ctx.listName looks like a guid List list = _clientContext.Web.Lists.GetById(new Guid(listName));
So taking a step back, this would be the first time I wrote something that uses both client object model at once!
JohnLiu.NET |
1 Comment | tagged
SharePoint in
code
SharePoint in
code 




Reader Comments (1)
How can I get ctx object?
I put on the PlaceHolderAdditionalPageHead
<SharePoint:ScriptLink Name="SP.js" LoadAfterUI="true" OnDemand="false" Localizable="false" runat="server" ID="ScriptLink1" /> but always 'ctx' is undefined message.
how can i get ctx instance?