using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace UpdateMasterPage
{
public partial class UpdateMasterPage: System.Windows.Forms.Form
{
public UpdateMasterPage ()
{
InitializeComponent();
}
private SecureString ConvertToSecureString(string password)
{
if (password == null)
throw new ArgumentNullException("password");
var securePassword = new SecureString();
foreach (char c in password)
securePassword.AppendChar(c);
securePassword.MakeReadOnly();
return securePassword;
}
private void button1_Click(object sender, EventArgs e)
{
Microsoft.SharePoint.Client.ClientContext cc = new Microsoft.SharePoint.Client.ClientContext("https://Gowtha.pnpdemo.com/");
SecureString secstring = ConvertToSecureString(“********”);
SharePointOnlineCredentials creds = new SharePointOnlineCredentials("gowtham@pnp.onmicrosoft.com", secstring);
// The SharePoint web at the URL.
Web web = cc.Web;
// We want to retrieve the web's properties.
cc.Load(web);
// Execute the query to the server.
cc.ExecuteQuery();
var a = web.Title; // For debug checks.
var master = web.CustomMasterUrl; // For debug checks.
web.CustomMasterUrl = "/_catalogs/masterpage/seattle.master"; // Or the original page desired.
web.MasterUrl = "/_catalogs/masterpage/seattle.master";
web.Update();
// Execute the query to server.
cc.ExecuteQuery();
}
}
Thursday, 28 March 2019
Home
/
CSOM
/
Masterpage
/
OSLO
/
Seattle
/
SharePoint 2013
/
sharepoint Framework
/
SharePoint Online
/
How to Change SharePoint Online masterpage from Seattle to Oslo using CSOM
How to Change SharePoint Online masterpage from Seattle to Oslo using CSOM
About Gowtham
I'm a software developer who enjoys building solutions, exploring new tech, and helping others grow through clean and simple content. This blog shares real-world coding tips, Power Platform how-tos, AI experiments, and lessons learned from hands-on experience.
SharePoint Online
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment