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
Sridhar JujjavarapuSridhar Jujjavarapu 

How to call a apex class from button

Hi


how to call a apex class or method from  botton click ,please give me sample code for that 

Thanks in advance
Sri.
SF AdminSF Admin
Hi 
Please check: http://sfdc.arrowpointe.com/2009/01/08/invoke-apex-from-a-custom-button-using-a-visualforce-page/

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.

Regards
padmapadma
 Hi ,

 This is a class:::
public class classname{
public objectname instance{get;set;}

public classname(){
instance =new objectname();
}// this will be allocate the memory

public void save(){
// you are write a logic here
}// this is a method

}

page:
<Apex:page controller="classname">
     <Apex:form>
         <Apex:pageBlock>
             <Apex: commandButton value="Button" action="{!save}">
          </Apex:pageBlock>
     </Apex:form>
</Apex:page>
 In this action attribute to invoke the method.
Is this my basic Knowledge.
Regards,
padma