ladybugg333
ladybugg333

Reputation: 11

Kentico transformation - Hide field if empty

I have a transformation with a url link that is working, but need to hide the field, if empty. If there is no catalog link, how can I hide this? Should I use a String.IsNullOrEmpty? If so, exactly how do I write it as a url link?

<div><p><strong>View <a href="<%# Eval("CatalogURL") %>" target="_blank"> Pathway for this Program</a>.</strong></p></div>

Upvotes: 1

Views: 313

Answers (1)

liamgold
liamgold

Reputation: 283

I would recommend looking up the Transformation Methods available on the documentation here.

You will probably want to do something like:

<%# IfEmpty(Eval("CatalogURL"), "", string.Format("<div><p><strong>View <a href=\"{0}\" target=\"_blank\"> Pathway for this Program</a>.</strong></p></div>", Eval("CatalogURL"))) %>

Upvotes: 1

Related Questions