Play Games

Search This Blog

Monday, October 24, 2016

How to access custom label in apex class

Solution : using Label.labelName We can access custom label.
where labelName is the api name of custom label created
Example :
Create the custom label as shown in the image below.

Apex Class:
public class CustomLabel {
    public String labelStr {get;set;}
    public CustomLabel () {
        labelStr = label.Custom_Error_Message;
    }
}
Visualforce Page :
<apex:page controller="CustomLabel">
    <b>Custom Label</b> :{!labelStr}

</apex:page>
Output :

No comments:

Post a Comment