Home

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

%3CLINGO-SUB%20id%3D%22lingo-sub-1009707%22%20slang%3D%22en-US%22%3EC%23%20ClientContext%20-%20Removing%20Image%20from%20Page%20Banner%20on%20Modern%20Page%20-%20SP%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1009707%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20ClientSidePage%20in%20C%23.%20I%20have%20been%20able%20to%20make%20the%20page%2C%20but%20I%20can't%20figure%20out%20how%20to%20remove%20the%20image%20from%20the%20Page%20Banner.%20The%20option%20exists%20to%20remove%20the%20image%20and%20keep%20the%20banner%20when%20in%20the%20UI's%20edit%20mode.%3C%2FP%3E%3CUL%3E%3CLI%3EI%20know%20about%20the%20ClientSidePage.LayoutType%20to%20%22Home%22%2C%20but%20that%20removes%20the%20entire%20banner%2C%20including%20the%20title.%3C%2FLI%3E%3CLI%3EI%20have%20tried%20the%20following%3A%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EclientSidePage.PageHeader.LayoutType%20%3D%20ClientSidePageHeaderLayoutType.NoImage%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E...%20but%20that%20has%20no%20effect.%3C%2FP%3E%3CP%3EHow%20do%20I%20remove%20the%20image%20from%20the%20page%20banner%20without%20removing%20the%20entire%20banner%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAS%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1009707%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EModern%20Page%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1025537%22%20slang%3D%22en-US%22%3ERe%3A%20C%23%20ClientContext%20-%20Removing%20Image%20from%20Page%20Banner%20on%20Modern%20Page%20-%20SP%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1025537%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F420219%22%20target%3D%22_blank%22%3E%40AS911%3C%2FA%3E%26nbsp%3BI%20have%20the%20same%20issue.%20Original%20page%20has%20no%20banner%20and%20image%2C%20after%20applying%20the%20template%20the%20page%20has%20a%20banner%20and%20no%20image.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1031624%22%20slang%3D%22en-US%22%3ERe%3A%20C%23%20ClientContext%20-%20Removing%20Image%20from%20Page%20Banner%20on%20Modern%20Page%20-%20SP%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1031624%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJust%20to%20say%20that%20with%20the%20PnP%20Powershell%20I%20was%20able%20to%20update%20the%20page%20header%2C%20setting%20it%20to%20NoImage.%20You%20can%20create%20the%20page%20and%20then%20use%20the%20following%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3C!--%20StartFragment%20%20--%3E%3C%2FP%3E%3CDIV%3E%3CSPAN%3E%24page%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EPageHeader%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ELayoutType%3C%2FSPAN%3E%20%3CSPAN%3E%3D%201%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3E%3C!--%20StartFragment%20%20--%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3CDIV%3E%3CSPAN%3E%24page%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3ESave%3C%2FSPAN%3E%3CSPAN%3E()%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI%20haven't%20tried%20it%20in%20C%23%2C%20but%20since%20the%20PnP%20PowerShelluses%20CSOM%20I%20am%20sure%20it%20is%20possible.%20Let%20me%20know%20if%20you%20have%20questions%20on%20how%20to%20achieve%20it.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ERegards%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CSPAN%3E%3C!--%20EndFragment%20%20--%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CP%3E%3C!--%20EndFragment%20%20--%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1036354%22%20slang%3D%22en-US%22%3ERe%3A%20C%23%20ClientContext%20-%20Removing%20Image%20from%20Page%20Banner%20on%20Modern%20Page%20-%20SP%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1036354%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365643%22%20target%3D%22_blank%22%3E%40Carlos_Marins%3C%2FA%3E%26nbsp%3BThanks%20for%20getting%20back.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESetting%20it%20to%20%221%22%20(casted%20to%20the%20ClientSide%3CSPAN%3EPageHeader%3C%2FSPAN%3E%3CSPAN%3ELayoutType%2C%20since%20that%20is%20the%20type%20that%20CSOM%20is%20looking%20for)%20still%20has%20no%20effect%2C%20unfortunately.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EWe%20are%20currently%20opting%20to%20make%20the%20change%20through%20JS%20instead.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EI'll%20try%20to%20give%20an%20update%20where%20that%20leads.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1036481%22%20slang%3D%22en-US%22%3ERe%3A%20C%23%20ClientContext%20-%20Removing%20Image%20from%20Page%20Banner%20on%20Modern%20Page%20-%20SP%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1036481%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F420219%22%20target%3D%22_blank%22%3E%40AS911%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20you%20using%20the%20CSOM%20library%3F%20Which%20version%3F%20Using%20the%20latest%20PnP%20PowerShell%20I%20was%20able%20to%20save%20a%20page%20with%20the%20Header%20set%20to%20NoImage.%3C%2FP%3E%3CP%3EI%20am%20also%20looking%20for%20a%20way%20to%20have%20a%20parameter%20-HeaderLayoutType(something%20like%20that)%20included%20in%20the%20Add-PnPClientSidePage%20so%20this%20problem%20is%20solved.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1036842%22%20slang%3D%22en-US%22%3ERe%3A%20C%23%20ClientContext%20-%20Removing%20Image%20from%20Page%20Banner%20on%20Modern%20Page%20-%20SP%202019%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1036842%22%20slang%3D%22en-US%22%3E%3CP%3EHey%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365643%22%20target%3D%22_blank%22%3E%40Carlos_Marins%3C%2FA%3E.%3C%2FP%3E%3CP%3EWe%20are%20using%20the%20latest%20SharePointPnPCoreOnline%20(v3.15.1911)%2C%20which%20uses%20the%20Microsoft.SharePointOnline.CSOM%20(%26gt%3B%3D%2016.1.19404.12000).%3C%2FP%3E%3CP%3EWe%20opted%20to%20just%20remove%20the%20page%20header%20through%20an%20Application%20Extension%20SPFx%2C%20then%20have%20a%20webpart%20read%20the%20site%20page%20properties%20to%20create%20the%20title%20as%20needed.%3C%2FP%3E%3CP%3ESo%20problem%20is%20%22resolved%22%2C%20as%20in%20we%20found%20an%20alternate%20solution%20that%20did%20not%20involve%20the%20PnPClientSidePage%20commands%20that%20suited%20our%20needs.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
AS911
Occasional 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,

 

AS

5 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
$page.Save()
 
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.
 
Regards,

@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.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies