function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RJoshiRJoshi 

Can i enable and disable fields on a visualforce page , based on some conditions?

hi , Can i enable and disable fields on a visualforce page , based on some conditions? If yes , Please let me know how ? Thanks Rjoshi
Best Answer chosen by Admin (Salesforce Developers) 
wesnoltewesnolte

Hey

 

An example of the above suggestion might be:

 

public Class MyController{

 

public boolean enabled{get;set;}

public String blah{get;set;} 

 

public MyController(){

  enabled = true;

 

 

public void disable(){

enabled = false;

}

 

<apex:page>

<apex:form id="theform"> 

  <apex:inputText value="{!blah}" disabled="{!enabled}"/>

<apex:commandButton value="disable" action="{!disable}" rerender="theform"/>

</apex:page> 

 

Cheers,

Wes 

All Answers

YRYR

Yes, you can enable/disable fields & controls using public properties of its controller class.

Just create boolean public properties and bind with fields & controls and set its values as TRUE/FALSE according to your needs.

YCRYCR
Thanks
wesnoltewesnolte

Hey

 

An example of the above suggestion might be:

 

public Class MyController{

 

public boolean enabled{get;set;}

public String blah{get;set;} 

 

public MyController(){

  enabled = true;

 

 

public void disable(){

enabled = false;

}

 

<apex:page>

<apex:form id="theform"> 

  <apex:inputText value="{!blah}" disabled="{!enabled}"/>

<apex:commandButton value="disable" action="{!disable}" rerender="theform"/>

</apex:page> 

 

Cheers,

Wes 

This was selected as the best answer