C# ClientContext - Removing Image from Page Banner on Modern Page - SP 2019

Copper Contributor

I am trying to create a ClientSidePage in C#. I have been able to make the page, but I can't figure out how to remove the image from the Page Banner. The option exists to remove the image and keep the banner when in the UI's edit mode.

  • I know about the ClientSidePage.LayoutType to "Home", but that removes the entire banner, including the title.
  • I have tried the following:



clientSidePage.PageHeader.LayoutType = ClientSidePageHeaderLayoutType.NoImage;



... but that has no effect.

How do I remove the image from the page banner without removing the entire banner?


Thanks in advance,



6 Replies

@AS911 I have the same issue. Original page has no banner and image, after applying the template the page has a banner and no image.

Hey guys,


Just to say that with the PnP Powershell I was able to update the page header, setting it to NoImage. You can create the page and then use the following code:


$page.PageHeader.LayoutType = 1
I haven't tried it in C#, but since the PnP PowerShelluses CSOM I am sure it is possible. Let me know if you have questions on how to achieve it.

@Carlos_Marins Thanks for getting back.


Setting it to "1" (casted to the ClientSidePageHeaderLayoutType, since that is the type that CSOM is looking for) still has no effect, unfortunately.


We are currently opting to make the change through JS instead. I'll try to give an update where that leads.

Hi @AS911,


Are you using the CSOM library? Which version? Using the latest PnP PowerShell I was able to save a page with the Header set to NoImage.

I am also looking for a way to have a parameter -HeaderLayoutType(something like that) included in the Add-PnPClientSidePage so this problem is solved.

Hey, @Carlos_Marins.

We are using the latest SharePointPnPCoreOnline (v3.15.1911), which uses the Microsoft.SharePointOnline.CSOM (>= 16.1.19404.12000).

We opted to just remove the page header through an Application Extension SPFx, then have a webpart read the site page properties to create the title as needed.

So problem is "resolved", as in we found an alternate solution that did not involve the PnPClientSidePage commands that suited our needs.

$page = Get-PnPClientSidePage -Identity Home.aspx
$lwc = $page.PageListItem.FieldValues.LayoutWebpartsContent
$newLwc = $lwc -replace ""imageSourceType":4,"", ""imageSourceType":0,""
Set-PnPListItem -List "SitePages" -Id $page.PageId -Values @{"LayoutWebpartsContent" = $newLwc} -SystemUpdate
This code here should remove the image from the page. ImageSourceType = 4 is default, ImageSourceType = 0 is none, ImageSourceType = 2 is custom image.