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
Tushar Bapat 22Tushar Bapat 22 

bind visualforce page input field to string variables in custom controller

How to bind visualforce page input fields like firstname, lastname, city to string variables firstname, lastname, cityName in custom controller?
These fields are not part of any object created in salesforce.
Best Answer chosen by Tushar Bapat 22
Tushar Bapat 22Tushar Bapat 22
Yes this helped me. 

All Answers

sfdcMonkey.comsfdcMonkey.com
Hi Tushar, 
 here is the sample code :
<apex:page controller="mysearchbutton">
    <apex:form>
        <apex:pageBlock id="pb">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!searchRecords}" value="Search" rerender="pb"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="2">
          
                <apex:outputLabel value="First Name"/>
                <apex:inputText value="{!firstname}"/>
                
                <apex:outputLabel value="Last Name"/>
                <apex:inputText value="{!lastname}"/>
                
                <apex:outputLabel value="city "/>
                <apex:inputText value="{!city }"/>
                
                
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

public class mysearchbutton{
    
    public String  firstname { get; set; }
    public String lastname{ get; set; }
    public String  city { get; set; }
    

    public PageReference searchRecords(){
         system.debug('firstname --> ' + firstname);
         system.debug('lastname --> ' + lastname);
         system.debug('city --> ' + city);
        return null;
    }
}

i hope it helps you.
      Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
    thanks 
http://sfdcmonkey.com  (http://sfdcmonkey.com )
Tushar Bapat 22Tushar Bapat 22
Yes this helped me. 
This was selected as the best answer
sfdcMonkey.comsfdcMonkey.com
cheers to you, kindly close your question by choosing right best answer so it will helps other in future
Thanks