New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :https://t.co/p4F3oeQagK

Friday 3 August 2012

If you click on button a text msg should display on vf page

VF
<apex:page controller="temp">
<apex:form >
<apex:commandButton value="Click!" action="{!hai}"> 
<apex:actionSupport event="onclick" reRender="hi"/>
</apex:commandButton>
<apex:outputPanel id="hi">
{!msg}<!--By default it won't display, After clicking on button it will display-->
</apex:outputPanel>
</apex:form>
</apex:page>

APEX
public wih sharing class temp {

    public String msg { get; set; } //By default it has null value

    public PageReference hai() {
        msg = 'Hi'; //After clicking on this button it will display this value
        return null;
    }
}

No comments:

Post a Comment

Labels