More in this section
Forums / Designing & Styling / Conditional Code in Master file

Conditional Code in Master file

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Marz
    Marz avatar
    7 posts
    29 Aug 2012
    25 Sep 2012
    Link to this post

    Is it possible to write conditional code in Sitefinity Master pages?.. so if no widgets are used for a placeholder, the markups for the empty placeholder does not show on the website. 

    For emaxple, I have this code for my sidebar in my Master file:

    <div class="Sidebar">
       <asp:contentplaceholder id="Sidebar" runat="server" />

    and this creates a div box in my wesbite (and I have some borders via CSS for this box).  Is it possible to include some conditional code to this so if a widget is dragged into this placeholder, it shows the div box on the website and if no widget is used, it doesn't show the div box.

  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    10 Nov 2016
    28 Sep 2012
    Link to this post
    Hello Marz,

    You can check if the div contains any html with a JQuery script on the master page. Something similar to this should do the job:

      if ($(".Sidebar").html().length > 0) {
    Take a look at the following forum thread for further reference: 

    All the best,
    Jen Peleva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered