How to disable button in Visualforce page?

Visualforce page:

 <apex:page controller="Sample" sidebar="false">
    <apex:pagemessages />
    <apex:form >
        <apex:commandButton value="Disable" disabled="{!disabl}" action="{!dis}"/>
    </apex:form>
</apex:page>


Apex Controller:

public class Sample
{
    public Boolean disabl {get;set;}
   
    public void dis()
    {
        disabl = true;
    }
}


Output:
After clicking the button

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete