function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
outsauce1.3890939920067253E12outsauce1.3890939920067253E12 

Display image in visualforce page based on currentpage parameter

Hi

I am trying to display image in visualforce page based on condition. The condition applied is on {$CurrentPage.parameters.startpage} value.

If {$CurrentPage.parameters.startpage} = "xyz" then display image <apex:image  url="xxxxxxx"> else display image <apex:image  url="yyyy">

I click a link and try to get the parameters of that url. Based on those parameter, I have to render different images on VF Page.

www.testurl.com/?value=xyz

www.testurl.com/?value=abc

Please find below the code I am using and let me know whats wrong there

<apex:image value="{If({!$CurrentPage.parameters.startpage}='xyz','/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000' , '/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000')}" />
Best Answer chosen by outsauce1.3890939920067253E12
sfdcfoxsfdcfox
Your merge fields are incorrect; it appears at best that you're trying to combine JavaScript with Visualforce syntax. Try the following changes:

<pre>
<apex:image value="{!If($CurrentPage.parameters.startpage='xyz','/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000' , '/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000')}" />
</pre>

All Answers

sfdcfoxsfdcfox
Your merge fields are incorrect; it appears at best that you're trying to combine JavaScript with Visualforce syntax. Try the following changes:

<pre>
<apex:image value="{!If($CurrentPage.parameters.startpage='xyz','/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000' , '/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000')}" />
</pre>
This was selected as the best answer
outsauce1.3890939920067253E12outsauce1.3890939920067253E12
Hi 

Many thanks. It works absolutely fine as I wanted. 

How can I nest another IF condition in false parameter of main IF Condition:

For example:
<apex:image value="{!If($CurrentPage.parameters.startpage='xyz','/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000' ,  {!If($CurrentPage.parameters.startpage='abc',''/servlet/servlet.ImageServer?id=015D0000002Dkr2&oid=00DD0000000CWRY&lastMod=1388753305000'' , false)})}" />

I get error if I do it this way.

Any help will be much appreciated. Thanks again for the solution provided earlier.