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
dipudipu 

How do I include a commandButton with no action no server call in a VF page.

I have a confirmation dialog with Ok and Cancel button. When user clicks OK I would call server action to proceed and on cancel no server call is necessary.

 

I want to use the apex:commandButton for both to make sure that they use the same css style. Even if I do not have the action parameter the command submits a call to the server. 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
hemantgarghemantgarg

I guess you can use the command buttons also like following :-

 

<apex:commandButton value="Cancel" onclick="return false;" />

 

by doing so it will not call anything at server side, in fact it will do nothing, give it a try.

 

 

All Answers

sfdcfoxsfdcfox

apex:commandButton is a controller invoker, so it will invoke the server. You could use an input field of type button (" <input type="button" class="btn" value="Label"/> "), or a button (" <Button style="btn">Label</Button> "), You can get faster response from an apex:commandButton by using "immediate="true"", which bypasses normal validation and such.

hemantgarghemantgarg

I guess you can use the command buttons also like following :-

 

<apex:commandButton value="Cancel" onclick="return false;" />

 

by doing so it will not call anything at server side, in fact it will do nothing, give it a try.

 

 

This was selected as the best answer
unidhaunidha
I also want to have the command without calling the controller method.It just for Close button but I need to rerender some panel.So if we using normal html button we cannot use rerender.Any idea?