Hide and Show in Salesforce Visualforce Page

Hide and Show in Salesforce Visualforce Page

Sample code:

Apex:

public class SampleController {

    public boolean displayPopup {get; set;}
    
    public void closePopup() {
    
        displayPopup = false;
        
    }
    
    public void showPopup() {
    
        displayPopup = true;
        
    }
    
}

Visualforce page:

<apex:page controller="SampleController">
    <apex:form >
        <apex:commandButton value="Show" action="{!showPopup}"/><br/>
        <apex:outputPanel layout="block" rendered="{!displayPopup}">
            Testing Hide and Show!!!
            <apex:commandButton value="Hide" action="{!closePopup}"/>
        </apex:outputPanel>
    </apex:form>
</apex:page>

Output:            

Leave a Reply