HOW TO: Hide web part when it's empty

Contributor

I have a web part I wrote that I want to hide when there is no content in it (like the News web part). How do I do that?

2 Replies

@smithme There's usually an option to hide the web part if there's nothing to show. It's definitely on 'News', although maybe not on every web part.

 

shinypurple_0-1632312508144.png

 

Sorry, I wasn't more clear. I am writing a custom webpart. I want it to take up zero vertical space on the page when it is empty. How do I programmatically, tell my webpart to display:none;