+ Start a Discussion
padmaja shivanepadmaja shivane 

how to create lookupfield intovisualforce

Vijay NagarathinamVijay Nagarathinam
Hi Padmaja,

If you want to display a lookup field in your visualforce page, try this
 
<apex:page standardController="Contact">
<apex:form >
<apex:pageBlock >
<apex:pageblocksection>
<apex:inputField value="{!contact.accountid}"/>
</apex:pageblocksection>
</apex:pageBlock>
</apex:form>
</apex:page>


 
Abhinav MIshraAbhinav MIshra
Hi Padmaja,

This block of code is for displaying lookup field in your visualforce page.


public with sharing class AdminController
{
    public AdminSetting__c adsetting{get;set;}
    public AdminController
 {
   adsetting=new AdminSetting__c();
 }
}


The below is how your visualforce tag should be

<apex:inputField value="{!adsetting.user_ref_field__c}" />


Please note i dont know your API names of object and field so you need to make sure to replace with exact names


Thanks!
Reetesh Makkar
Shaijan ThomasShaijan Thomas
<apex:inputField value="{!<FieldorVariable,which the value stores>}" id="LookId">
	<apex:image Id="LookupImg" url="/s.gif" styleClass="lookupIcon" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';"/>
</apex:inputField>

Try this, Make it best answer if it works
Shaijan