To avoid closing of sharepoint designer edit form after saving/or to redirect to
another url after saving of Sharepoint designer form.
Source Reference :-
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/7aff3de2-4250-47ac-9175-2fdc0a685005/how-to-control-the-redirect-url-after-saving-content-in-a-data-form-view-control
Details:
I
have customized a Page Layout to include a custom Data Form View Web Part that
will allow users to enter comments on a news story page in a publishing site.
I was having a difficult time because when I clicked the button to save
the data to the list, everything saved correctly, but the control was
redirecting me to the AllItems.aspx page of the list. This wasn't the desired
behavior since the end user would prefer to see that their comment was posted on
the news story page and wouldn't know what the AllItems.aspx page was for.
The save button that was created in the XSL seciton of the web part was:
<SharePoint: SaveButton runat="server" ControlMode="New"
id="savebutton1" />
Microsoft has documented a RedirectUrl property on
this button that I figured could change what page was loaded after the user
saved the form data. However, try as I might I could not get it to work.Some
more searching lead me to this article:
http://office.microsoft.com/en-us/sharepointdesigner/HA101191121033.aspx
Which
details how to create a "Form Action" for a save button rendered in the XSL of a
DataFormWebPart. This was a great article, but it doesn't detail the code that
Sharepoint Designer outputs for this action. After following the instructions,
I discovered this code for a button:
<input type="button" value="Save"
name="btnSave" onclick="javascript:
{ddwrt:GenFireServerEvent('__commit;__redirect={}')}" />
When used
instead of my SharePoint: SaveButton above, the form saved it's data correctly,
and the current page that the form was submitted from was reloaded for the
user.
You could also put any URL in the __redirect={} that you want, for
example __redirect={http://www.google.com} or
__redirect={/news/PressReleases/}
Notice that there are no quotes around
the URLs passed into the __redirect directive.
Thanks, it works for me!
ReplyDelete