2

I need NewForm.aspx page redirects to custom page on item added to list. I've done this by changing Source parameter in URL after NewForm.aspx has been loaded. But it makes the page to load twice. Is there a way to change Source without page reload?

  • Why not change the Source in the NewForm link itself? Is there a reason why you are changing the Source parameter after NewForm.aspx has been loaded? – Ransher Singh Jun 14 '17 at 19:54
  • I try keep all customization in one place. In this way user could open NewForm in many ways including direct link but still get redirected. – Chetvergov Jun 15 '17 at 6:37
4

The answer to the question is No. After the page has been loaded and sent to the browser, there is no way to change the query string without reloading the page. Browsers only allow the part of the URL after "#" to be changed: http://authority/path?que=ry&str=ing#anchor

You can either move the dynamic code earler (modify the link to the new form) or later (set the source parameter to target a custom page - let the custom page have dynamic code that redirects dynamically based on the system state). Can you tell us more about the requirement?

  • Thanks for your reply! Is there a chance to use any kind of window preload function so this reloads looks more transparent? – Chetvergov Jun 15 '17 at 6:39
  • 1
    If you do it server side during the initial page load, you can do a HTTP redirect. That will make the browser redirect before showing anything. – JanErikGunnar Jun 15 '17 at 7:45
  • I've got the idea. Then there's no way to implement conditional rederecting, e.g. different URLs for Save and Cancel buttons? I don't use server side coding on this project, only javascript client side – Chetvergov Jun 15 '17 at 9:00
  • 1
    Well, you could for example redirect to a page, e.g. "RedirectAfterEdit.aspx?ItemID=X&TimeStamp=Y" which checks whether the item was recently updated or not (last modified > timestamp), then redirects to different pages accordingly. – JanErikGunnar Jun 15 '17 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.