Detect if webpart has content

Duncan Koza asked on December 2, 2019 17:48

I have a button on my page that toggles the display of two web parts. If both of these two web parts don't have content (and therefore won't be rendered), I don't want my button to appear either.

Is there a way to detect if a web part has content, from an other web part?

Recent Answers

Peter Mogilnitski answered on December 2, 2019 18:33 (last edited on December 2, 2019 21:18)

What kind web parts are these? Standard Kentico web parts or custom ones made by you?

What you normally can do is to use macro to check whether data for web part is available or not. If there is no data you disable web part. if you click on little triangle you can enter macro that will return true/false base on your data. If there is no data web part will be invisible.

Image Text

0 votesVote for this answer Mark as a Correct answer

Duncan Koza answered on December 11, 2019 19:14

Just standard Kentico web parts. But the issue is that I have an HTML button, that appears on my web page only for mobile devices. This button toggles the css display value for certain web parts. Basically, I want to check to see if the web part was even rendered, because if it wasn't due to no data then I don't need the button to be visible.

Not sure if there is a way to check the id of a web part to see if it has data, if not, don't show my button.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.