+ 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"/>
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 

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