Wednesday, May 4, 2011

Redirect Users to Thank You page from NewForm.aspx after form submission

Here is my requirement: I've a SharePoint request tracking system. When users create a new entry, what I want is to redirect them to "Thank you! We have received your request. We will get back to you on this soon!", typical acknowledgement page :-)

So, to redirect page after form submission in SharePoint, create a custom NewForm.aspx, hide the default "Ok" and "Cancel" buttons, and then insert the below code:

Redirect NewForm EditForm Submit button:

<input type="button" value="Submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={/sites/marketing/SitePages/thankyou.aspx}')}" />

Change SharePoint Cancel button Redirect:
<input name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={/sites/marketing/SitePages/Home.aspx}')}" type="button" value="Cancel">

Alternate approach: Using Source URL Parameter in SharePoint List Forms
If you want to send users to some other page (Doesn't matter whether the user press "Ok" or "Cancel"), SharePoint allows us to control OK and Cancel button behavior with the "source" parameter. Here is an example:

There is one issue when using Source parameter is: you will get Thank you page even when you click on "Cancel" button. Lets mitigate that by adding a jQuery: It binds a function with "Cancel" button's click event. (Edit the NewForm.aspx page and add a CEWP, just below NewForm Fields. Place this script in a text file, upload and point it from a CEWP)
sharepoint redirect page after form submission
SharePoint redirect cancel button
<script type="text/javascript" src=""></script>

<script type="text/javascript">
      $('input[value=Cancel]').click(function() { window.location.replace("");});

Related Post: SharePoint Survey Redirect to Thank You Page on Finish

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:


  1. Thanx! This artical really helped me ! but one problem is that when me submited data i dont need to go back button (<=)

  2. Hi,
    I have added one HTML button on the Default SharePoint 2010 List Edit form dynamically using Jquery.

    $(priotr).before('<_input id="btnTest" Name="btnTestSubmit" type="button" onclick = "javascript: {ddwrt:GenFireServerEvent(\'__commit\')}" value="Submit Button"/>

    at the time of button click. i get error "Object expected"
    Any idea why.
    i also tried other option.
    $(priotr).before('<_input id="btnTest" Name="btnTestSubmit" type="button" onclick="javascript: __doPostBack(\'btnTestSubmit\''+ ','+'\'__commit\')" value="Submit Button"/>

    in the second approach function is working but data is not saving in the list.
    Thanks in advance

  3. JavaScript to Check for Required Fields: Name, Phone Number or Mailing Address, and E-Mail Address
    Prompts for Missing Required Fields
    Once the Required Fields Have been Entered Cookie is Placed on the users computer.
    If same user attempts to open page with cookie, user is redirected to a new web page stating the form has been filled out.

  4. Hi Can you please help with anonymous users. The &Source= does not work for anonymous users


Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...