how to set a <a> tage visible false when ID is missing

sarathlal s asked on September 19, 2014 06:20

I have a transformation <a href="http://<%# Eval("BookingURL")%>/widget/index/?source=x&id=<%# Eval("ID")%>" target="_blank" class="SubscriptionButton"><%# ResHelper.GetString("Title")%>

I need to set the visibility false when there is no ID. How can i do this? Please help

Recent Answers


Brenden Kehren answered on September 19, 2014 14:33

Add this to your < a > tag:

style="<%# (Eval<int>("ID") <= 0 ? "display: none;" : "") %>"
1 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on September 19, 2014 14:37

Hello, if the column ID is empty you can use:

<%# IfEmpty(Eval("ID"),"","<a href=\"http://"+ Eval("BookingURL")+"/widget/index/?source=x&id="+ Eval("ID")+"\" target=\"_blank\" class=\"SubscriptionButton\">"+ ResHelper.GetString("Title")+"</a>") %>

otherwise if you need to compare ID with other value you can use:

<%#IfCompare(Eval("ID"),0,"<a href=\"http://"+ Eval("BookingURL")+"/widget/index/?source=x&id="+ Eval("ID")+"\" target=\"_blank\" class=\"SubscriptionButton\">"+ ResHelper.GetString("Title")+"</a>","") %>

More detail you can find below: https://docs.kentico.com/display/K81/Reference+-+Transformation+methods

3 votesVote for this answer Mark as a Correct answer

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