CoolWriteups Solved: SharePoint Redirect From NewForm.aspx

Hello

Have you ever had the need to redirect your NewForm.aspx page to a custom page or another page in your site?

The solution is:

Place the following javascript code after the
<asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>

Add this code after the line above in your NewForm.aspx page.
<script type=”text/javascript” language=”javascript”>
function PreSaveAction() {
var srcUrl=GetSource();
var newSrcUrl = “http://www.yournewpage.aspx“;
var i = aspnetForm.action.lastIndexOf(srcUrl);
aspnetForm.action = aspnetForm.action.substring(0,i) + newSrcUrl ;
return true;
}
</script>

And that’s it. Good luck 🙂

 

Derek Halstead is a SharePoint consultant as well as the founder and principal of CertifiedSolutionsAustralia.com and CoolWriteups.com. He has 16 years of experience in the IT industry, with over ten years focused on Microsoft SharePoint. He can be reached by using the Contact Me link in the top menu.
Back to Top