Welcome! I'm a Microsoft Certified Trainer (MCT) specializing in SharePoint, .Net, SQL Server and related technologies. I'm a Senior Instructor for MAX Technical Training (Cincinnati area).

Looking for a SharePoint user group? Cincinnati SharePoint User Group


6/27/2009

SharePoint: Redirecting to a page after adding a New item to a list

 

There are times when you want a user to add an item to a list without displaying the list, either before or after they fill out the “New Item” form.

 

To get them to the form is easy. Go to the list, click the New button and note the URL. Copy the URL and paste it as a link in an Announcement, a links list or a Content Editor Web Part. When the user clicks your link they will go directly to the New item page.

But… when they click OK they will the go to the list, not back to your page.

 

The fix is easy...        Add “source=” to the end of the link.

 

 

1) Go to the list and click the new button. You will see a URL like:

http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales%2FLists%2FTasks%2FAllItems%2Easpx


2) copy the URL and change the part after Source= to the desired destination. The following will send them back to your home page:

http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales

 

Absolute or Relative?

Best practice would be to use a relative URL (no HTTP or server name) so your site will work when you have internet and intranet access to the same site. Something like "Source=/sites/sales/" or "Source=/sites/sales/mycustompage.aspx".

To return to the home page add this URL as a link in your Announcement, a links list or a Content Editor Web Part:

Absolute:

http://www.yourserver.com/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=http%3A%2F%2Fwww.yourserver.com%2Fsites%2Fsales

Relative:

/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=%2Fsites%2Fsales


In the examples above I did not always escape the slashes:  /  =  %2F
Any slash after the "?" should be escaped.

 

.

0 comments: