Feb 06 2019 04:02 AM
Hi SharePoint gurus.
I have a SharePoint Modern page where I want to hide the header of a web part. I have taken out the ID of the header and used the code snippet web part, but the header is still visible. Also the code snippet web part is visible. I thought that the web part only would be visible when editing the page? Please look below:
Forgive Me for My poor code abilities, but I am very new to this kind of working wtih SharePoint.
Greetings from Denmark
/Frank
Feb 06 2019 07:28 AM
The code snippet webpart doesn't do anything - the code is not executed. It's only used to display code so you can use it to document programs and such. There is not a way currently to add code to a modern page.
Feb 06 2019 09:37 AM
SolutionAs others have mentioned, the code snippet web part just displays code, it doesn't execute it.
You should also be aware that trying to override out of the box styles is not good practice. Those IDs are subject to change and they will change as they are dynamically generated.
Feb 07 2019 01:36 AM
Thank you so much for quick reply. Last night i did find a script editor webpart for modern pages on GitHub, and will take a look at that instead. It is not some great changes I want to make, so I will give it a try.
https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor
Frank
Feb 07 2019 01:37 AM
Thank you so much for quick reply. Last night i did find a script editor webpart for modern pages on GitHub, and will take a look at that instead. It is not some great changes I want to make, so I will give it a try.
https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor
Frank
Mar 11 2019 07:28 AM
Will the code snippet web part actually work at some point? I don't see any purpose for a non working code snippet web part.
Mar 11 2019 08:34 AM
Probably not, Microsoft do not want people to be making code changes to sites as they will inevitably break when a future update comes along (which seems to happen every other day at the moment).
Rob
Los Gallardos
Mar 12 2019 12:14 AM
Hi Rob. I can see it from there point of view. I have earlier worked in a software company that had a very open product, so the customers could make a lot of local changes. But every time we made an upgrade of the product, the customers got a lot of errors in their custom solutions. And we were the one to blaime :\
Frank
Jul 08 2019 09:43 AM
From my perspective the Code Snippet web part does work. It allows you to share pieces of code. It isn't meant to act as a window to run code, but a means of sharing pieces of code in a visual manner.
Jul 26 2023 03:11 AM - edited Jul 26 2023 03:13 AM
@Amanda DowningThe main problem for me is, that after publishing the code via the code snippet web part, it cannot be copied (Strg+C) from the sharepoint site. For the browser is looks like a picture.
Does someone have a solution for this?
Feb 06 2019 09:37 AM
SolutionAs others have mentioned, the code snippet web part just displays code, it doesn't execute it.
You should also be aware that trying to override out of the box styles is not good practice. Those IDs are subject to change and they will change as they are dynamically generated.