{"id":6102,"date":"2020-05-11T08:57:26","date_gmt":"2020-05-11T08:57:26","guid":{"rendered":"https:\/\/www.softreetechnology.com\/?p=6102"},"modified":"2020-05-11T08:57:26","modified_gmt":"2020-05-11T08:57:26","slug":"how-to-create-modern-site-page-using-csom","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/","title":{"rendered":"How to create modern site page using CSOM"},"content":{"rendered":"\n<p><strong>Introduction:-<\/strong><\/p>\n\n\n\n<p>             In a SharePoint modern page, we can access various SharePoint sites easily within an organization. We can also find the news from the site, frequent site which is visited and other suggested news posts as well as the events. It provides a fast and easy way to develop a modern responsive page using modern webparts.<\/p>\n\n\n\n<p>             For creating a modern page first, we create the list item object in the site page library and assign the correct content type with some other additional properties to list item object.<\/p>\n\n\n\n<p>Follow the code\nshown below:<\/p>\n\n\n\n<p><strong>Step 1:- <\/strong>Set the credential for SiteUrl.<\/p>\n\n\n\n<p><strong>Step 2:-<\/strong> Get the Library name.<\/p>\n\n\n\n<p><strong>Step 3:- <\/strong>Add the template file in list item by giving the ServerRelativeUrl having modern page name (take modern page name as per your requirement. Here we have used &#8220;MyModernPage&#8221;).<\/p>\n\n\n\n<p><strong>Step 4:- <\/strong>Add the correct content type and properties for the modern page.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   class Program\n;      {\n        static void Main(string[] args)\n        {\n            using (ClientContext ctx = new ClientContext(\"https:\/\/contoso.SharePoint.com\/sites\/NewSite\"))\n            {\n                string passWord = \"PassWord\";\n                SecureString securstr = new SecureString();\n                foreach (char ch in passWord)\n                {\n                    securstr.AppendChar(ch);\n                }\n                ctx.Credentials = new SharePointOnlineCredentials(\"username@contoso.onmicrosoft.com\", securstr);\n                List Library = ctx.Web.Lists.GetByTitle(\"site pages\");\n                ctx.Load(Library);\n                ctx.ExecuteQuery();\n                \/\/ pagesLibrary is List object for the \"site pages\" library of the site\n                ListItem oItem = \nLibrary.RootFolder.Files.AddTemplateFile(\"\/sites\/NewSite\/SitePages\/MyModernPage.aspx\", TemplateFileType.ClientSidePage).ListItemAllFields;\n\n               \/\/ Make this page a \"modern\" page\n               oItem [\"ContentTypeId\"] = \"0x0101009D1CB255DA76424F860D91F20E6C4118\";\n               oItem [\"Title\"] = System.IO.Path.GetFileNameWithoutExtension(\"MyModernpage.aspx\");\n               oItem [\"ClientSideApplicationId\"] = \"b6917cb1-93a0-4b97-a84d-7cf49975d4ec\";\n               oItem [\"PageLayoutType\"] = \"Article\";\n               oItem [\"PromotedState\"] = \"0\";\n               oItem [\"CanvasContent1\"] = \"&lt;div>&lt;\/div>\";\n               oItem [\"BannerImageUrl\"] = \"\/_layouts\/15\/images\/sitepagethumbnail.png\";\n               oItem .Update();\n               ctx.Load(oItem );\n               ctx.ExecuteQuery();\n               Console.WriteLine(\"successfully created mordern page in library\");\n               Console.ReadLine();\n        }\n    }\n}  <\/code><\/pre>\n\n\n\n<p><strong>Step 5<\/strong>:- Now its created, we can check it in the sitepage Library.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-1024x561.png\" alt=\"\" class=\"wp-image-6103\"\/><\/figure>\n\n\n\n<p><strong>Keywords:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>How to create modern page in SharePoint using CSOM.<\/li><li>Programmatically create a modern site page using client server object model.<\/li><li>Create SharePoint modern page using CSOM.<\/li><li>Using C# create a modern site page in SharePoint online.<\/li><li>Creating modern page in sitepage library using CSOM.<\/li><\/ol>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:- In a SharePoint modern page, we can access various SharePoint sites easily within an organization. We can also find the news from the site, frequent site which is visited and other suggested news posts as well as the events. It provides a fast and easy way to develop a modern responsive page using modern webparts. For creating a modern [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-6102","post","type-post","status-publish","format-standard","hentry","category-sharepoint"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create modern site page using CSOM - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create modern site page using CSOM - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"Introduction:- In a SharePoint modern page, we can access various SharePoint sites easily within an organization. We can also find the news from the site, frequent site which is visited and other suggested news posts as well as the events. It provides a fast and easy way to develop a modern responsive page using modern webparts. For creating a modern [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-11T08:57:26+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create modern site page using CSOM - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/","og_locale":"en_US","og_type":"article","og_title":"How to create modern site page using CSOM - Softree Technology","og_description":"Introduction:- In a SharePoint modern page, we can access various SharePoint sites easily within an organization. We can also find the news from the site, frequent site which is visited and other suggested news posts as well as the events. It provides a fast and easy way to develop a modern responsive page using modern webparts. For creating a modern [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/","og_site_name":"Softree Technology","article_published_time":"2020-05-11T08:57:26+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"How to create modern site page using CSOM","datePublished":"2020-05-11T08:57:26+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/"},"wordCount":216,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-1024x561.png","articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/","name":"How to create modern site page using CSOM - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#primaryimage"},"thumbnailUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-1024x561.png","datePublished":"2020-05-11T08:57:26+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#primaryimage","url":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-1024x561.png","contentUrl":"https:\/\/www.softreetechnology.com\/wp-content\/uploads\/2020\/05\/1-1024x561.png"},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/how-to-create-modern-site-page-using-csom\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create modern site page using CSOM"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=6102"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6102\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=6102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=6102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=6102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}