Wednesday, May 5, 2010

SharePoint 2010 - Redirecting a form

In MOSS the most efficient and reliable method of redirecting a form was to use a query string parameter. This is where you have the page url followed by a parameter. Site.com\page.aspx?source=targetURL for example.

In 2010 Microsoft has made a vast improvement where specifying the redirect URL in the custom form actually works. What is great about this is it allows for a page to go to two different locations based off wither the user hits save or cancel.

To implement find the onclick command for the button whose behavior you would like to change. It should be calling a GenFireServerEvent in the ddwrt namespace. Append ‘;__redirect={targetURL}’ following the commit or cancel filed. The field should now look like this
__commit;__redirect={ targetURL }

Save the page and you have a fully functioning redirect hidden from the users.

Many thanks to IOTAP for the pointer - http://web.iotap.com/Blogs/tabid/277/EntryId/7/Redirecting-to-a-custom-URL-from-Sharepoint-custom-forms.aspx

No comments: