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
OldDeadBugOldDeadBug 

Rendering a pageblocksection with if statement causing an error

Don't know quite what's up with this. Seems like it should be simple. Here's the relevant code:

 

<apex:pageBlockSection rendered="{!IF(Opp.Utility__c = "CA-SDGE","true","false")}"
            title="Login ..." id="Login"> 
     <apex:pageBlockSectionItem >
           <bUsername:</b>&nbsp;&nbsp; <apex:inputText value="{!username}" label="Username" required="true"/>
     </apex:pageBlockSectionItem>
     <apex:pageBlockSectionItem />
     <apex:pageBlockSectionItem >
           <b>Password:</b>&nbsp;&nbsp; <apex:inputSecret value="{!password}" label="Password" required="true"/>
     </apex:pageBlockSectionItem>
</apex:pageBlockSection>

 If I remove the rendered statement the page works fine. With the statement, I get the following error:

 

"The element type "apex:pageBlockSection" must be terminated by the matching end-tag "</apex:pageBlockSection>""

 

I have the matching end tag, and the same rendered statement is working to render a button on the page.

 

Any ideas why this isn't working?

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

The problem is the use of quoted strings inside a quoted string.  Use single quotes for inner strings. 

All Answers

Alok_NagarroAlok_Nagarro

Hi,

 

just replace below formula in pageBlockSection -

 

rendered="{!IF(Opp.Utility__c = 'CA-SDGE',true,false)}"

 

Hope it would help u.

aballardaballard

The problem is the use of quoted strings inside a quoted string.  Use single quotes for inner strings. 

This was selected as the best answer
OldDeadBugOldDeadBug

Ahh!! That worked. Thanks!!