How to Hide Command Button In Visualforce page

Tuesday, August 11, 2015

How To Hide Command Button in visualforce page after clicking on it ?


Do follow the code as mention below :

Take one variable of 'Boolean'

then simple apply that variable in method as 'True' value which is called from your button,

Let me do some code here,

Apex Class :

Public Class HideButton{
      
  public Boolean disable {get;set;}

Public HideButton(){
        
        }

public void HideButtonMethod(){

// put your condition if needed and set below variable under that condition

disable = true;
}
}

Visualforce page :

<apex:page Controller="HideButton" sidebar="false" showHeader="False">
<apex:form>
<apex:outputpanel> 
<apex:pageblock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!HideButtonMethod}" Value="Submit" disabled="{!disable}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:outputpanel>
</apex:form>

</apex:page>


Note : You can also Hide Button from the JavaScript


No comments: