Search This Blog

Thursday, April 29, 2010

Automatic Redirection to the Data Form Web Part page on Close / Save / Cancel

In SharePoint - We know that if Source parameter is used in the QueryString in browser, the page is redirected back to the URL specified in Source querystring parameter.

While creating Data Form Web Part we need this functionality.

a) A link to create a new item in a list is specified in DFWP. When the user saves or cancels on the new page, it should be redirected back to the original page where this new link was specified
b) Links to a list item display page. After visiting the page, when user clicks Close on the page, again it should be redirected to the page from where the link was clicked on.

Since the DFWP can be on any page we want it to be generic so that on whichever page DFWP is placed i.e. say page X , after the destination page is visited and "close / cancel / ok" is clicked it should come back to page X.

Here is how to do it:
First create two parameters in DFWP as shown in the images below. These pick up values from Server Variables of IIS Server.

Now in DFWP where you specified a URL append this:

Source=<xsl:value-of select="$MyURL"></xsl:value-of>?<xsl:value-of select="$QS"></xsl:value-of>

(You also need to encode the strings)

and now when users click from the link specified in the URL and they hit close / cancel / save they
are redirected back to the page in Source querystring parameter.

This is what I have used in the past and now.

Have you used any other method for this? If yes - am interested to know.

-- Mohan

No comments: