Monday, 30 January 2017

Is there a way to restrict the buttons on a standard page to be displayed top or bottom only ?


Generally we will be displaying buttons on both bottom and top of the page using below code

Code
<apex:page standardController="lead" extensions="appointmentcontroller">
  <apex:form>
      <apex:pageBlock> 
          <h1>Congratulations</h1>
          This is your new Page
           <apex:pageBlockButtons>
                   <apex:commandButton action="{!saveAndCongrat}" value="Save" reRender="test"/>
                   <apex:commandButton value="Cancel" action="{!cancelredirect}" />         
           </apex:pageBlockButtons>
       </apex:pageBlock>
   </apex:form>
</apex:page>

Output



What if you want to display button only on top or only on bottom ? then change the above code to below format by adding location attribute where you can specify top, bottom, or both - it defaults to both in pageBlockButtons

Code
<apex:page standardController="lead" extensions="appointmentcontroller">
  <apex:form>
      <apex:pageBlock> 
          <h1>Congratulations</h1>
          This is your new Page
           <apex:pageBlockButtons location="bottom">
                   <apex:commandButton action="{!saveAndCongrat}" value="Save" reRender="test"/>
                   <apex:commandButton value="Cancel" action="{!cancelredirect}" />         
           </apex:pageBlockButtons>
       </apex:pageBlock>
   </apex:form>
</apex:page>

Output


1 comment:

  1. Yes, their is an attribute in apex command button called location eg.

    ReplyDelete

Tools for Lightning Web Component Development

 Below are the tools required for Web Component Development 1. Chrome Browser (Prefered) You can download it from Google 2. Visual Studio Co...