Tuesday, August 26, 2014

How to Use Custom label in apex code?

How to Use  Custom label in apex code?

Custom labels are used to store custom text values which can be accessed in apex code or visualforce pages. It is also possible to translate these custom values in different languages. A custom label can hold up to 1000 characters in it and an org can have a total of 5000 custom labels.
You can Create a custom label by navigating to set up -> create -> custom label

In the below example let us see how we can access the custom label in apex. Let's assume we have created a custom label of name category with a value "A Custom Label Value"



Visualforce page

<apex:page controller="custlabelcontroller">
   <apex:form >
     <apex:pageblock >
       Value stored in custom label is: {!customValue}
     </apex:pageblock>
   </apex:form>
</apex:page>



Controller


Public class custlabelcontroller{
Public string customValue{get;set;}
  Public custlabelcontroller(){
  customValue = Label.category;
  }
}











1 comments:

pokemon said...

An excellent information provided thanks for all the information i must say great efforts made by you. thanks a lot for all the information you provided.

SolitaireOnline.io
KrunkerioGame.Com
TetrisOnline.io

Post a Comment

 
| ,