Passing Query String Values as Part of the Source Query String Parameter in SharePoint

1 minute read

SharePoint has a nice capability on many pages where, if you pass a Query String parameter named Source with a value of a page URL, the user is returned to that page when they are done with the activity.  An example would be when a user clicks on an ‘Add new document’ list on a site where they are a contributor.  The current page’s URL is specified as the Source parameter, and when the user is done adding the document, they return to the current page.

There are times when you’re sending your user off from a page that relies on its own Query String values to configure it.  So, how do you pass those values along with the source so that when the user gets back, they see the page configured correctly?  The trick is a little encoding magic.  Configure your URL to look like something like this:

<a href="{concat('/PG/Policy%20Guidance/Forms/DispForm.aspx?ID=', @ID,
         '&Source=', $URL,
         '?Series=', $Series,
         '%26ContentArea=', $ContentArea)

This will evaluate to something like this URL:


By placing a question mark (?) after the Source URL value and encoding the ampersand (&) between parameter/value pairs as %26, you can ensure that those values are passed back to the Source URL when the user returns to that page.  This will also work if you are building your own forms and are using the ddwrt:GenFireServerEvent(‘__redirectsource;’) function.

Technorati tags: , ,


  1. Hi Marc, going crazy, thought you could help. I have a dataview document libary on the dispform.aspx. I have a parameter set called ParameterCaseID. Have a link on the doc lib as follows: Upload a new Document for a Case…

    I press Upload a new document, I go to the upload.aspx. Once I load the document (I see the CaseID in the url), it goes to the editform.aspx. I can’t seem to get the parameter to pass to the editform.aspx, then back to the Dispform.aspx. I want the document to be only for the caseid parent.

    Your thoughts on my url mess.

  2. Hi Marc,

    I have custom Newform.aspx and Editform.aspx in which I am using DVWP.

    1) I need to pass value selected in masterpage navigation like year,quarter to newform.aspx as querystring but it redirects me to blank page.

    Also to note here is that I am using concept of Intermediate page to redirect to newform or editform based on ID exist or not for current user.

    so if you could help me out using intermediate page how can I get querystring to be passed would be appreciable.


    • Anjalee:

      It’s sort of impossible for me to tell you the answer on this one. It sounds like you’ve got some code in place on your “intermediate page” which isn’t working properly and you’ll simply need to debug it.


      • Hi Marc,

        Thanks for the reply and yes it was issue with the code I was writing and was missing some value to pass…Anyways it has been resolved now…

        Now , I have requirement where in I need to check if for selected year and quarter any item exist for user or not and redirect to Newform.aspx if no item found otherwise redirect to Editform.aspx.

        I was just wondering if you could give some idea about the template or code needs to be write in intermediate page to achieve this would be very grateful…


  3. I used it like this in a straight Javascript file to generate url:


Have a thought or opinion?