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
Nagarjun TNagarjun T 

how to write a apex code for contact detailed page using custom controller

Raj VakatiRaj Vakati
<apex:page controller="ConCntrl">
    <apex:detail subject="{!con.Id}" relatedList="false" title="false"/>
    
</apex:page>
 
public class ConCntrl {

    public Contact con {get;set;}
    public ConCntrl(){
        con = [Select Id,Name from Contact where id =:apexpages.currentpage().getparameters().get('id')];
    }
    
}
You can pass contact id from the URL as shown below to the controller 
/apex/COnpage?id=0036A00000OYyK8QAL

 
Nagarjun TNagarjun T
Hello Raj V,
VisualForce error bro
System.QueryException: List has no rows for assignment to SObject 
Class.apex6.<init>: line 4, column 1
Amit Chaudhary 8Amit Chaudhary 8
Hi Nagarjun T,

You need to pass  valid ContactRecord ID in URL like below
/apex/Cnnpage?id=0036A00000OYyK8QAL