How to get record id from standard controller using Apex in Salesforce?

Sample Code:

Visualforce page:

<apex:page standardcontroller="account" extensions="Sample">

Apex Controller:

public class Sample {

    public Id Aid {get;set;}
    public Sample(ApexPages.StandardController controller) {
        Account acc = new Account();
        Aid = controller.getId();

Output in Account Page layout:


Sharing is Caring!!! Share this with your friends!!!

submit to reddit