AnuRaj
AnuRaj

Reputation: 27

disable the working of save button

I have done a VF page in this pages controller. I have written a query to get some record. If the condition is false then an error message is shown. If the error message is shown then I want to disable the working of the save button.

Is it possible to enable the working of save button, or disable a save button? In Apex code.

Upvotes: 1

Views: 2057

Answers (1)

Matt K
Matt K

Reputation: 7327

The disabled attribute of an <apex:commandbutton> can be set to enable/disable a button. Setting this attribute to a bound Apex variable would allow you to control whether or not the button is enabled in your Apex Controller or Extension.

Example Visualforce markup:

<apex:commandbutton action="{!save}" value="Save" id="theButton" disabled="{!myApexBooleanVariable}" />

Example Controller or Extension Apex code:

public Boolean myApexBooleanVariable {get;set;}

Upvotes: 1

Related Questions