Sample Code:
Visualforce page:
<apex:page controller=”Sample” tabStyle=”Account”>
<apex:form >
<apex:pageMessages />
<apex:pageBlock id=”pg”>
<apex:pageBlockSection columns=”1″>
<apex:outputField value=”{!con.FirstName}”/>
<apex:outputField value=”{!con.LastName}”/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
Visualforce page:
<apex:page controller=”Sample” tabStyle=”Account”>
<apex:form >
<apex:pageMessages />
<apex:pageBlock id=”pg”>
<apex:pageBlockSection columns=”1″>
<apex:outputField value=”{!con.FirstName}”/>
<apex:outputField value=”{!con.LastName}”/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public class Sample {
public Contact con {get;set;}
Id conId {get;set;}
public Sample() {
conId = ApexPages.currentPage().getParameters().get(‘conId’);
con = [SELECT FirstName, LastName FROM Contact WHERE Id =: conId];
}
}
Field:
Output:
Cheers!!!