How to Set Alternate CSS URL in Office 365 using CSOM?

In office 365, you can change the SharePoint Site Alternate CSS Property using CSOM Code. In this way, you can customize the host web’s alternate URL  using Provider hosted model. Below are the sample code to change the SharePoint Site alternate CSS property using CSOM code.

// Get the Web Object from the Client Context.

Web web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();

//Update the Alternate CSS property

web.AlternateCssUrl = web.ServerRelativeUrl + /SiteAssets/mycustom.css;
web.Update();

//Execute the query.
web.Context.ExecuteQuery();

 Please make sure that your customcss must have been uploaded to Asset Library before executing the above Client Side object Model code.

Do visit my other blogs on office365 below

1.Activate a sandbox solution using csom in office-365

2.Add office 365 security groups to the site collection administrators in office-365

Happy SharePointing Folks!!!

Leave a Reply

Your email address will not be published.