Forum Discussion
mytech1982
Sep 19, 2022Brass Contributor
How to create a modern page using cusotm templage in JSOM
Hi, Can any one advise how to create a modern page uisng custom page template in JSOM Any kind of help is appricieated. Thnaks,
ganeshsanap
Sep 20, 2022MVP
mytech1982 Check and try if there are any JSOM equivalent functions available for below CSOM code (code taken from this thread😞
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using ClientSidePage = OfficeDevPnP.Core.Pages.ClientSidePage;
using System.Security;
namespace CreatePageFromTemplate
{
class Program
{
static void Main(string[] args)
{
string userName = "email address removed for privacy reasons";
string password = "**************";
using (ClientContext clientContext = new ClientContext("https://Tenant.sharepoint.com/sites/SiteName"))
{
SecureString securePassword = new SecureString();
foreach (char c in password.ToCharArray())
{
securePassword.AppendChar(c);
}
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
// Load the template page
ClientSidePage page = clientContext.Web.LoadClientSidePage("Templates/MyTemplate.aspx");
// Create and Save the modern page based on the template
page.Save("IT_Australia1.aspx");
}
}
}
}
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.