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 

pagereference code for command button to go the page into detailed page,,???

public class apex4 {

    public PageReference Save() {
        return null;
    }

contact con=new contact();

    public contact newcon{get;set;}
    
    public apex4(){
    newcon=new contact();
    }
   public pagereference save(){
   contact coninsert=new contact();
    coninsert.lastname=newcon.name;
    coninsert.phone=newcon.phone;
    insert coninsert;
    
    pagereference pageref = new pagereference('/'+con.id);
    return pageref;
   
   } 
}
Vinod ChoudharyVinod Choudhary
Hi Nagarjun,

Fitrst of all pagereference in  always return pagereference not Null.

Try Below code:
 
public class apex4 {

 

contact con=new contact();

    public contact newcon{get;set;}
    
    public apex4(){
    newcon=new contact();
    }
	
   public pagereference save(){
   contact coninsert=new contact();
    coninsert.lastname=newcon.name;
    coninsert.phone=newcon.phone;
    insert coninsert;
    
    PageReference pageref = new PageReference('/' + con.id); 
	pageref .setRedirect(true); 
	return pageref;
   
   } 
}

Thanks
Vinod
Vinod ChoudharyVinod Choudhary
Hi Nagarjun,

Is it works?

If Yes then Mark my solution as the best answer. it will help others as well who face similar Issue.

Thanks
Vinod