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
NUBESNUBES 

Using "if / then" login in Visualforce

Hi, 

 

I have been through the visualforce documentation and although it has helped me a great detail in being able to provide a custom list of all my events, I would still like to build an if/then statement. Depending on a certain event name I would like the text to be bold for example. Does anyone know what code I can use? Below is my code

 

<apex:page controller="EventController" showHeader="false"> 

 

 

  <apex:repeat value="{!Events}" var="event" id="event_id">

 

      <p><a href="/apex/event_details?id={!event.id}">{!event.name}, {!event.Event_Date__c}</a>

      <br/>Description:&nbsp;{!event.Description__c }

 

    if {!event.name} = "marathon" then ....

 

</p><hr/>

 

  </apex:repeat>

                          

 

</apex:page> 

Best Answer chosen by Admin (Salesforce Developers) 
Force2b_MikeForce2b_Mike

To implement a conditional in VisualForce, you have to use the "{!IF(critieria, true, false)}" format. You can implement this within the Render= attribute or Style= (or Disable="" for a commandButton) on the various apex Tags to show/hide elements based on a condition. Alternatively, you embed that logic into your Apex Controller and have something like Render="{!showThisElement}" as a tag attribute.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_functions.htm

 

 

Also, be sure to use the PasteCode button () to paste code into messages. Makes it much easier to read.

 

Mike

All Answers

Force2b_MikeForce2b_Mike

To implement a conditional in VisualForce, you have to use the "{!IF(critieria, true, false)}" format. You can implement this within the Render= attribute or Style= (or Disable="" for a commandButton) on the various apex Tags to show/hide elements based on a condition. Alternatively, you embed that logic into your Apex Controller and have something like Render="{!showThisElement}" as a tag attribute.

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_functions.htm

 

 

Also, be sure to use the PasteCode button () to paste code into messages. Makes it much easier to read.

 

Mike

This was selected as the best answer
KingsleyKingsley
Thanks for answering, scrappydog, and for pointing out the Paste Code button!