Friday, August 30, 2013

Retrieve selected properties of website using SharePoint 2013 client object model



Here we will check how we can retrieve selected properties of website like title and description using SharePoint 2013 client object model. Also you can check:

- New for visual webpart for SharePoint 2013 and Visual Studio 2012

- eDiscovery in SharePoint Server 2013

- What's new for mobile devices in SharePoint 2013 ?

Below is the full code:

ClientContext context = new ClientContext("http://SiteURL");

Web web = context.Web;

context.Load(web, w => w.Title, w => w.Description);

context.ExecuteQuery();

lblTitle.Text = web.Title;

lblDescription.Text = web. Description;

Here the code will give you title and description of the website. If you want to retrieve anyother properties apart from Title and Description, it will give an exception because you only load these 2 properties to context object.

context.Load(web, w => w.Title, w => w.Description);


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Favorites More