1
votes

This is for a custom Editform.aspx being used to submit data to a custom list. Once the user completes the form, he should be able to hit a button or even the OK button, and have sharepoint submit the form data to the list, then redirect to the items Display form (dispform.aspx?ID='itemid'). I was able to get the ID of the current item by manipulating document.location.href. I tried to do a postback in javascript using __doPostBack with __commit and __redirect (redirecting to the URL displayform?ID='itemid'), but when the redirect happens, I see that the changes were not updated!

Anyone able to do something like this?

2

2 Answers

1
votes

You can get the form to redirect to any location after it's been posted by modifying the URL in the Source querystring parameter. Using javascript, you could look for a specific URL (/location/dispform.asp?ID=) in that querystring parameter and if it doesn't exist, redirect the page to itself, but with the Source parameter filled out to the location w/ ID that you want to send them to.

The hardest part will be parsing the current URL + parameters in javascript. There's some snippets of JS code I've found that make it a lot easier.

One of the bonuses of rewriting the EditForm URL this way is that the Cancel button will send the user to the DispForm page instead of where they originally came from, although most people probably use the back button.

0
votes

This lead me to solve my problem of a Form Action on my DispForm that would not take the list item ID to the custom EditForm. The following ended up working for me:

onclick="javascript: {ddwrt:GenFireServerEvent(concat('__redirect={ProgEditForm.aspx?ID=+',$ListItemId,'}'))}"

Where I have a DispForm parameter for ListItemID with

Parameter Source: Query String
Query String Variable: ID
Default Value: 0

Hope that helps someone else as this was near driving me crazy!