Pass Value From Visualforce Page To Controller

Controller:

Public with sharing class Sample {
    
    Public string myInput{get;set;}
    Public string myOutput{get;set;}
    
    Public void myMethod(){
        myOutput = myInput;
    }
}

Visualforce Page:

<apex:page controller="Sample">
    <!--Pass parameters from visualforce page to controller-->
    <apex:form>
        <apex:pageblock >
            Input Here - <apex:inputText value="{!myInput}"/>
            <apex:commandButton value="Submit" reRender="outputID" action="{!MyMethod}"/> 
        </apex:pageblock>
        <apex:pageblock >
            <b>Output Here - </b><apex:outputText value="{!myOutput}" id="outputID">
            </apex:outputText>
        </apex:pageblock>
    </apex:form>
</apex:page>

Output:

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5.00 out of 5)
Loading...

About Biswajeet

Biswajeet is my Name, Success is my Aim and Challenge is my Game. Risk & Riding is my Passion and Hard Work is my Occupation. Love is my Friend, Perfection is my Habit and Smartness is my Style. Smiling is my Hobby, Politeness is my Policy and Confidence is my Power.