Some Basic Code Syntax in Visualforce

We all know how to display dynamic data for Asp.net(<%>,<%#%>), Razor Based(@).  Similarly, in Visualforce Apex the syntax is

{! }

Let's see some syntax in Visualforce Apex with output

Step to Open developer console over your SalesForce developer account,

  • Profile -> Developer Console
  • File -> New -> Visualforce Page

Now just add new Visualforce Page,



I have given the name of Visualforce page as MyFirstSyntax.

I have just written the syntax for displaying (My Name,Today Date,Max Number,Min Number). Please find the below code and paste same over your visualforce page. Then just click the preview button and it will redirect you to newly created Visualforce.

Like,

https://c.ap2.visual.force.com/apex/MyFirstSyntax

  1. <apex:page>  
  2.     <apex:pageBlock title="My Dynamic Syntax">  
  3.         <table>  
  4.             <tr>  
  5.                 <td>  
  6.                     FirstName  
  7.                 </td>  
  8.                 <td>  
  9.                     {!$User.FirstName}  
  10.                 </td>  
  11.             </tr>  
  12.             <tr>  
  13.                 <td>LastName  
  14.                 </td>  
  15.                 <td>{!$User.LastName}</td>  
  16.             </tr>  
  17.             <tr>  
  18.                 <td>  
  19.                     Today Date  
  20.                 </td>  
  21.                 <td>  
  22.                     {!ToDay()}  
  23.                 </td>  
  24.             </tr>  
  25.             <tr>  
  26.                 <td>  
  27.                     Maximum Number From {2,5,55,66,108,19}  
  28.                 </td>  
  29.                 <td>  
  30.                     :----{!Max(2,5,55,66,108,19)}  
  31.                 </td>  
  32.             </tr>  
  33.             <tr>  
  34.                 <td>  
  35.                     Minimum Number From {2,5,55,66,108,19}  
  36.                 </td>  
  37.                 <td>  
  38.                     :---{!Min(2,5,55,66,108,19)}  
  39.                 </td>  
  40.             </tr>  
  41.         </table>  
  42.     </apex:pageBlock>  
  43. </apex:page>  
Output

 

Ebook Download
View all
Learn
View all