Redirect to custom page on OK or Cancel click in Newform.aspx sharepoint

In many cases you want to redirect the user to some custom page from newForm.aspx after adding an item ie "Ok" click or "Cancel" click. You can do that easily..
After creating a Custom Form in designer remove or hide the Ok and Cancel button and place this code instead.
<input type=”button” value="Submit” name="btnSaveonclick="javascript: {ddwrt:GenFireServerEvent(‘__commit;__redirect={userView.aspx}’)}" />
For the _redirect field give the custon page name you want to redirect to.
__commit in this statement will save the form details in to the list.
Similarly for cancel button add the below code.
<input type="button" value="Cancel" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={userView.aspx}')}" />

Comments

Popular posts from this blog

Clearing the Configuration Cache for SharePoint

SharePoint 2013 REST API CRUD Operations

Add List Item Attachments to Task Form using Nintex Workflow and Forms