Wednesday, July 10, 2013

Specify page to redirect to when adding a item (new form or edit form)

1. Open your Newform.aspx page
2. Add a CEWP. Type following line in your site url
(http://serverip/Lists/Test/NewForm.aspx?&toolpaneview=2 )
3. Paste below script in source code
<script>
function PreSaveAction() {
var srcUrl=GetSource();
var newSrcUrl = "http://www.google.com";
var i = aspnetForm.action.lastIndexOf(srcUrl);
aspnetForm.action = aspnetForm.action.substring(0,i) + newSrcUrl ;
return true;
}
< /script>


---------------------------------

JQuery for Cancel button:

Use the following jQuery code to override the behavior of the cancel button:


    $(function() {
      $('input[value=Cancel]').click(function() {history.go(-1);});
    });