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
SKT CloudComputingSKT CloudComputing 

difference between commandButton and pageBlockButton

I want to know difference between  commandButton and pageBlockButton for interview purpose.

Please suggest some important difference not the salesforce's definition.


Thanks You!

SKT
Prad NethasPrad Nethas
Hi SKT,

commond button is used to execute actions which we write in controller.
pageblockbutton is set of buttons like save,cancel which looks like standard buttons.

Regards
Prad
Marek Kosar_Marek Kosar_
<apex:pageblockbutton> is only about styling -> you have to put <apex:commandbutton> inside this section and then it have styling like standard button on page layouts(is on the top and bottom of page, centered)
Prad NethasPrad Nethas
And commond button may not be required to be placed in pageblock, but pageblockbuttons should be.
 
SKT CloudComputingSKT CloudComputing
Thanks Prad.

Does it mean that pageblockbutton also calls the "save","cancel" in controller?



 
Marek Kosar_Marek Kosar_

No, <apex:pageBlockButtons> is only another `block`, where you can hide your command buttons -> and then, they are automatically styled like standard buttons..as I wrote above..

Prad NethasPrad Nethas
No SKT,

It is only for styling.

Regards
Prad
SKT CloudComputingSKT CloudComputing
So if we want to style our commandbuttons we must write them inside  <apex:pageBlockButtons>. Ths is the only use of  pageBlockButtons.

These will not call constructor methods.

Did I get it correctly?

 
Prad NethasPrad Nethas
Not limited to that, using pageblockbuttons we can also do some actions like onkeypress, onkeydown, onmousedown/up/move/over and so on, which we declare in controller.

Regards
Prad
gv007gv007
Hello
can you take a close look of below documentation
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_pageBlockButtons.htm
 
Prad NethasPrad Nethas
Hi SKT,

Let us know if you have any further questions on it.

Regards
Prad