Hey, I am trying to use a conditional if statement in my web part layout. I have a boolean property that I want to use to effect content.
The problem is my conditional statement is not being resolved.
For e.g. {%if (ShowCTA) { %}
MY DIV I WANT TO HIDE
{% }#%}
Boolean property called: ShowCTA, If that's true I want to hide the div. Right now it's just printing out the entire if statement onto the DOM.
Any help will be appreciated. Thanks in advance
Dominic
Your logic is backwards. You currently have if it's true, show it. It needs to be if it's not true or false, show it, else hide it.
Simply update your logic to say:
{%if(!ShowCTA) { %} Now display your content {% } |(identity)GlobalAdministrator%}
Hey Brenden Thanks for the reply and I see what your saying but the actual problem I'm experiencing is that the if statement itself isn't working. It's just printing out the entire if statement including the sorrounding tags i.e. {%%} I'm using a web part layout.
Thanks for the thus far.
Regards, Dominic
What is the value of the dropdown list? You're using K# syntax so it should be Text/XML as the value.
I thought about that but when I create a new web part and go to the create the new layout it doesn't give me that drop down option ?
I beleive webpart layouts are always ASCX. So you have to write ASP.NET code.
<asp:PlaceHolder ID="ph1" runat="server" Visible='<%# !Eval<bool>("ShowCTA")'> Your visible content here. </asp:PlaceHolder>
Please, sign in to be able to submit a new answer.