How to get contact’s State, City, Country fields in Visualforce page?

How to get contact’s State, City, Country fields in Visualforce page?

Other Address Fields:

  1. OtherStreet
  2. OtherPostalCode
  3. OtherCity
  4. OtherCountry
  5. OtherState

Mailing Address Fields:

  1. MailingStreet
  2. MailingCity
  3. MailingCountry
  4. MailingState
  5. MailingPostalCode



Sample Code:


Visualforce page:


<apex:page controller=”Sample” sidebar=”false”>
<apex:form >
    <apex:pageblock mode=”edit”>
        <apex:pageblockSection title=”Contact Information”>
            <apex:inputField value=”{!cont.FirstName}”/>
            <apex:inputField value=”{!cont.Lastname}”/>
            <apex:pageblockSectionItem >
                Address
                <apex:inputField value=”{!cont.OtherStreet}”/> 
            </apex:pageblockSectionItem> 
            <apex:pageblockSectionItem >
                Postal Code
                <apex:inputField value=”{!cont.OtherPostalCode}”/> 
            </apex:pageblockSectionItem>            
            <apex:pageblockSectionItem >
                Postal City
                <apex:inputField value=”{!cont.OtherCity}”/> 
            </apex:pageblockSectionItem>           
            <apex:pageblockSectionItem >
                Postal Country
                <apex:inputField value=”{!cont.OtherCountry}”/> 
            </apex:pageblockSectionItem>                         
            <apex:inputField value=”{!cont.Email}”/>               
            <apex:inputField value=”{!cont.Phone}”/>   
            <apex:inputField value=”{!cont.MobilePhone}”/>                                
            <apex:inputField value=”{!cont.OtherPhone}”/>               
            <apex:inputField value=”{!cont.Birthdate}”/> 
        </apex:pageblockSection>       
        <apex:pageblockButtons location=”bottom” >
            <apex:commandButton value=”Save”/>
            <apex:commandButton value=”Cancel”/>
        </apex:pageblockButtons>
    </apex:pageblock>
</apex:form>
</apex:page>



Apex Controller:


public with sharing class Sample
{
    public Contact cont {get;set;}
}



Output:



Leave a Reply