You need to sign in to do that
Don't have an account?
![Nishad Basha Nishad Basha](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
How to display the contact detail page using visualforce page?
our requirement is when i click detail page button i want show the one contact details of that page. please give one example code for that scenario.please give some ideas.
Amit Chaudhary 8
How to display the contact detail page using visualforce page?
when i click the Detail Page button i need to display Detail Page records in the page.can you please give me the example of above scenario.
Hi, Krishna Sambaraju
visualforce page
Visualforce page (name: ContactDetailPage) Add the gotoContactDetailPage method to the controller or the extension class of the standardController of the current visualforce page.
Assuming your current visualforce page displays a list of contacts as shown in the below visualforce page
In the above VF page you can see a comman button "Goto DetailPage", which has an apex:param. The id of the contact is assigned to a controller variable contactId.
Hope this helps.
Hi, Krishna Sambaraju
above code is not getting result. can ypu please send me another code with example.
Your requirement is not clear. Please share the VF page and the controller, and give your requirement clearly. For example, on clicking the button do you need to go to the standard page layout of contact or a custom visualforce page, or do you want to display the details in the same visualforce page etc
In the above example, on clicking the button it navigates to a custom visualforce page. If you want to it to navigate to standard page layout change the controller method as below.
Regards,
Krishna.
details in the same visualforce page
ContactDetailPage: ContactListController:
ContactListPage:
Hope this helps.
above code not working properly .please give me another example about above scenario.
How to display the contact detail page using visualforce page?
when i click the Detail Page button i need to display Detail Page records in the page.can you please give me the example of above scenario.
Can you specify what is not working properly? I have given a working example. I have tested the functionality before sharing the code here. Please share your visualforce page and the controller, then I will have an idea about your requirement. You wanted to display the contact details on the same page, do you mean only the contact details, or you also want the related lists to be displayed. If you can provide a screenshot of what you are looking for, I will be able to help.
Regards,
Krishna.
<apex:page controller="ext_contactDetails">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title="Contacts ">
<apex:pageBlock title="Contacts Lists">
<apex:pageBlockTable value="{!con}" var="cc">
<apex:column headerValue="Name">
<apex:commandLink value="{!cc.Name}" action="{!gotoContactDetailPage}">
<apex:param name="ccId" value="{!cc.Id}" assignTo="{!contactId}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!cc.FirstName}"/>
<apex:column value="{!cc.LastName}"/>
<apex:column value="{!cc.Phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
--------------------
vf page 2:
<apex:page standardController="Contact">
<apex:detail relatedList="false" />
</apex:page>
----------------------
Controller:
public class ext_contactDetails {
public List<Contact> con {get;set;}
public string contactId {get;set;}
public ext_contactDetails(){
con = [SELECT Id, Name, FirstName, LastName, Phone FROM Contact Limit 10];
}
public PageReference gotoContactDetailPage()
{
return new PageReference('/apex/vf5?id=' + contactId);
}
}
<apex:pageBlock title="Contacts View for Ambassadors">
<apex:form >
<apex:pageBlockTable value="{!contacts}" var="a" id="list">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.gender__c}"/>
</apex:pageBlockTable>
</apex:form>
</apex:pageBlock>
</apex:page>
For your reference, I have added a code example below. Please Mark this as the best answer if you find your solution.
Thanks and Regards,
Suraj Tripathi