Articles about European Sharepoint Hosting Service
SharePoint 2013 Hosting – HostForLIFE.eu :: How to Custom Save Button On Custom SharePoint List Forms?
We have already discussed in our previous blog, how to make a custom list form using Sharepoint Designer. Now, we will create custom buttons that will save data to a Sharepoint list without writing any code in REST or JSOM. Now, go to Sharepoint Designer and open the custom new form that we have created from the forms gallery of the list in Sharepoint Designer as shown below.

Click on CustomNewForm.aspx and this would open the aspx code of the CustomNewForm in Sharepoint designer.
The custom new form looks like below in the browser.
As you can see, there are two Save Buttons on the form.
To remove the Save buttons on the top find the below piece of code,
And add the highlighted code as below.
This will hide the above save button on the form so the new custom form looks like this.

Now add the following code to add the custom button and use OOTB Sharepoint functionality to save the data in the Sharepoint list.
1 2 3 |
<tr> <td> <button type="button" value="Save And Exit" name="btnSave" onclick="javascript:{ddwrt:GenFireServerEvent('__commit;__redirect={/teams/******/Pages/Home.aspx}')};">Save And Exit</button> </td> </tr> |
Now, the form will have a custom button Save and Exit which will save the data in a sharepoint list just like OOTB sharepoint button.

Advantages of custom Button
- We can redirect the page anywhere we like after saving data in the list.
- We can run custom code by calling a javascript function (Discuss in next blog) to run validations and set values based on button click which is not possible in PreSaveAction functionality (to be discussed in the next blog)
- No need to write custom Rest or JSOM code to save data.
Hope this is helpful. Feel free to post comments if you have any query.
Print article | This entry was posted by Peter on April 5, 2018 at 7:15 am, and is filed under European SharePoint 2013 Hosting. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |