Thursday, 19 February 2015

Setting AlternateCSS URL of SharePoint site from CSOM

With the improvements made to SharePoint client side API  it is possible to update the Alternate CSS property of SPWeb from CSOM code. The property can be updated from .Net CSOM client or from JS or REST. For example to set the alternate CSS from JavaScript,  the following script can be added to a Script Editor  web part on any page in the SharePoint site  in which we want to apply alternate CSS style.
var clientContext;
var website;

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', OnReady);

function OnReady() {
    clientContext = SP.ClientContext.get_current();
    website = clientContext.get_web();
    clientContext.executeQueryAsync(OnUpdateSucceeded, onUpdateFailed);

function OnUpdateSucceeded () {

function onUpdateFailed (sender, args) {
    alert('Error in update ' + args.get_message());

The latest versions CSOM SDK can be downloaded from SharePoint Server 2013 Client Components SDK or SharePoint Online Client Components SDK

1 comment:

  1. Works Brilliantly - Many Thanks for this :-)