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();
}
}
Home
/
CSOM
/
Masterpage
/
OSLO
/
Seattle
/
SharePoint 2013
/
sharepoint Framework
/
SharePoint Online
How to Change SharePoint Online masterpage from Seattle to Oslo using CSOM
Tags
CSOM
Masterpage
About GowthamPower Platform and Copilot Studio architect sharing practical Microsoft engineering notes, implementation patterns, and lessons learned from real projects.
Subscribe to:
Post Comments (Atom)
No comments
Post a Comment