WebHosting

Thursday, July 7, 2011

Updating the title of a Web Part

using System; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.WebParts;  namespace SampleCode {     class UpdateWebPartTitle     {         static void Main()         {             ClientContext oClientContext = new ClientContext("http://MyServer/sites/MySiteCollection");             File oFile = oClientContext.Web.GetFileByServerRelativeUrl("Default.aspx");             LimitedWebPartManager limitedWebPartManager = oFile.GetLimitedWebPartManager(PersonalizationScope.Shared);              oClientContext.Load(limitedWebPartManager.WebParts,                 wps => wps.Include(                 wp => wp.WebPart.Title));              oClientContext.ExecuteQuery();              if (limitedWebPartManager.WebParts.Count == 0)             {                 throw new Exception("No Web Parts on this page.");             }              WebPartDefinition oWebPartDefinition = limitedWebPartManager.WebParts[1];             WebPart oWebPart = oWebPartDefinition.WebPart;             oWebPart.Title = "My New Web Part Title";              oWebPartDefinition.SaveWebPartChanges();              oClientContext.ExecuteQuery();          }     } }

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

เค•िเคธเค•े เคนिเคธ्เคธे เคฎें เคฎें เคฏे เคงเคฐเคคी

เคšिเคก़िเคฏों เค•ा เค˜เคฐ เคœเคฒ เคฐเคนा เคนै  เค‡ंเคธाเคจ เค–ुเคถ เคนै เค•ि เคฏे เค†เค— เคฆूเคฐ เคนै เค…เคญी เค•เคญी เคคो เค†เคเค—ी เค˜เคฐ เคคเค•  เคคेเคฐा เคญी เค˜เคฐ เคœเคฒेเค—ा เค•เคญी เคฌेเคœुเคฌाเคจ เคนै เค•ुเค› เคฌोเคฒเคคे เคจเคนीं เคนै เคฆिเคฒ เคฎें เคฆुเค– ...