Design Tip 1: Hyperlinks Should Always Contain the Source

May 14, 2008 at 2:10 pm Leave a comment

This tip was taken from SharePoint Online Help Topic – Return your Customer Back to your Data View

Original topic:

When a user clicks ANY link in a web application I have created, the URL passed to the new page contains the source location the user came from. If you examine the URL in the default lists and items in SharePoint, you will notice that they almost always contain the ‘&Source’ variable.


If the URL contains the source, you can use it in a Query String variable or in a Navigate to Source Form Action. You will be able to control how a user moves through your web application and therefore control the user’s actions and perceptions in the application. If you control there perception in the web application, there is nothing you cannot do.

When a user clicks the Create New Item link on a page on my site, they will be redirected to the Newform.aspx page I have customised (the page could be called anything because I control where the hyperlink points). But, when the user clicks Save or Cancel on the new form, where is the user sent?

I like to have the user automatically redirected to the next step, or sent back to the page they came from.

Add the code to the Hyperlink

Hyperlinks should contain the following attributes in the <a> tag to let the system know which page the user came from. A normal hyperlink might look like the following:

<a href=”http://..mysharepointsite/folders/link…”>link text</a>

In order to enable the source variable in SharePoint, all you need to add is the following attributes:

OnClick=”GoToLink(this);return false;”


The new hyperlink would look like this:

 <a href=”http://..mysharepointsite/folders/link…” OnClick=”GoToLink(this);return false;”  target=”_self”>link text</a>

When the user clicks the the new link text, the target page will open and the URL in the address bar will contain the ‘&Source’ variable.

Put that Information to Good Use

The URL now contains a variable for the user’s source page, so what? How do I leverage this new found super power?

Form Buttons

If you right-click on a form button (for example, the Save or Cancel button), you will see an option for Form Actions in the pop-up menu. Select Form Actions and you will open the Form Actions dialog box. You can now add the Navigate to Source action to the button and when the user clicks it, the button will perform it’s action (for example, Commit or Cancel) and then return the user to the page they came from.


Entry filed under: SharePoint Tips and Tricks. Tags: , , , , , .

SharePoint Contact Lists play nicely with Outlook Design Tip 2: Deleting and Restoring a List Item destroys Workflows

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

%d bloggers like this: