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

Posted: November 16, 2009 in Custom Form, Sharepoint Designer

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="btnSave" onclick="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}')}" />

  1. highly useful post…….

  2. Does your website have a contact page? I’m having trouble locating it but, I’d like to send you
    an email. I’ve got some recommendations for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it expand over time.

  3. Amos says:

    Hello my family member! I want to say that
    this article is amazing, nice written and come with almost
    all important infos. I’d like to see extra posts like this .

  4. I do not even know how I ended up here, but I thought this post was great.
    I don’t know who you are but certainly you are going to a famous blogger if you are not already 😉 Cheers!

  5. Kim says:

    This code is great. I’m using it on a new form entry page. When the user clicks save, I want to redirect it to the same record on another edit form. So basically, I want to set the url to something like this: <input type="button" value="OK" name="btnFormAction" onclick="javascript: {ddwrt:GenFireServerEvent(' __commit ;__redirect={/Lists/WorkOrder/AddPartsOnSave.aspx?ID=xxx. Where the xxx is the same record I was just on but on a different form. Is this possible?

  6. manikanta says:

    Hi i am using sharepoint 2013… this work on default newform.aspx page….if yes..pls tell me how can i use this sharepoint 2013 deisgner because i didn’t see any button script in newform.aspx…..pleas ehelp me

  7. perfume says:

    naturally like your website however you need to test the spelling
    on quite a few of your posts. A number of them are rife with spelling problems and I in finding it
    very bothersome to tell the reality however I’ll surely
    come back again.

  8. Rockie says:


    Thank You!

    Best regards,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s