Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > IFEmpty statement wont work View modes: 
User avatar
asovrano-opera21 - 10/13/2013 4:44:45 PM
IFEmpty statement wont work
Dear Sir, I'm going crazy with the following statement:
<%# IfEmpty(Eval("ProductsVideoLink"),"", "<a href=\"" + CustomFunctions.ReturnUrlSrc(
Eval("ProductsVideoLink").ToString()) + "\" class=\"products\">" + Eval("ProductsVideoLinkText") + "</a>") %>

I don't want the link to exist if not set, it's like a button and cannot be hidden in another way.
Instead in the source I see this:
<a href="" class="products"></a>

It is completely ignored !
Can someone help me, please ?
Thank you very much and Best Regards

User avatar
Kentico Support
Kentico Support
kentico_janh - 10/14/2013 3:38:14 PM
RE:IFEmpty statement wont work

The third parameter is returned only when the first one is not Null so maybe your field is empty like an empty string (not like Null value). However I would recommend you to let your method to return the the link and call it in transformation just like this:

<%# CustomFunctions.ReturnUrlSrc(Eval("ProductsVideoLink").ToString()) %>

And in the ReturnUrlSrc function you check if the parameter is empty or not and then it returns an empty string or the entire <a>...</a> markup. Is it clear?

Best regards,
Jan Hermann