apex:CommandButton Component

apex:CommandButton component is used to create a button on Visualforce page. <apex:CommandButton>must always be a child of<apex:form> component, which means to create a button apex:CommandButton must written in apex:form tag. Button in Visualforce page is rendered as an HTML output element. 

Example

apex:CommandButton Component Attributes

Action Action attribute is used to determine what action should be performed when we click on “Submit button”.
AccessKeyAccessKey attribute is a string type.The keyboard access key that puts the command button in focus
DisableIt is a Boolean type. If we want to disable the button we should give it as “True”. If set to true, the button appears disabled. If not specified, this value defaults to false.
DirDir attributes is used to display text direction on the button.
ImagesIt is a String Type. The absolute or relative URL of the image displayed as this button
RerenderIt is a Boolean type. It specifies whether the component is rendered on the page.

Visualforce page

As shown in above Visualforce page<apex:CommandButton>must always be a child of<apex:form> component. To create command button add apex:commandbutton component and enter the value for the button. Now we must add action attribute to the button. This action attribute is used to determine what action should be performed when we click on “Submit button”.

Output

apex:commandbutton component

Conclusion : In this Salesforce tutorial, we have learned about apex:CommandButton component and it’s attributes with an example. In our upcoming Salesforce tutorial, we will learn about apex:pageBlockButton.