IfEmpty transformation

Les Girvan asked on November 16, 2021 18:21

Hi Guys,

I have a blog on my site that has has both a video URL link and a blog teaser Image for the subject and I am trying to put an ifEmpty entry in my transformation so when there is no video link supplied, it will show the blog teaser image. I have tried

<%# IfEmpty(Eval("VideoURL"), "GetImage("BlogPostTeaser")", Eval("VideoURL")) %>

But this throws an error message:

[TempITemplate.Template]: http://server/CMSVirtualFiles/Transformations/=vg=5da44e6c-a3db-4675-86e9-cbff278da00f/CMS.BlogPost/blog_holding.ascx(7): error CS1003: Syntax error, ',' expected

This does not really help me as I dont know where the supposed , is missing from, can you advise please?

Regards

Correct Answer

Juraj Ondrus answered on November 17, 2021 09:35

Why are you adding the second parameter as string? It should be just like:

< %# IfEmpty(Eval("VideoURL"), GetImage("BlogPostTeaser"), Eval("VideoURL")) % >

Without the quotes around GetImage function.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Les Girvan answered on November 17, 2021 18:00

Thanks Juraj, that's the answer, thank you :)

0 votesVote for this answer Mark as a Correct answer

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