tags:

views:

275

answers:

1

When a list item is added to a sharepoint list i want to redirect to a thank you page.

how can i do that in an itemreceiver?

+3  A: 

I guess you could redirect on the ItemAdding event. But I would generally not recommend using event receivers for something like this. Better create your own New Item ASPX page, add the list item programmatically when the user clicks the Ok button. When the list item add is all done then you redirect to the Welcome page from your custom ASPX page.

Lars Fastrup
what do you mean by adding the list item programatically?
raklos
Yes, by using the SPListItemCollection.Add() method.
Lars Fastrup
My list is deployed as a feature. should i have a .cs code behind for the Newform.aspx page that I have? what method should this be implemented in within this .cs file? my sharepoint knowledge is weak so the more info the merrier. thanks!
raklos
Just out of interest Lars - why would you not recommend and Event Receiver?
Ryan
Raklos: Hmm, there is no short answer to this. But modifying the NewForm.aspx page is tricky. You should, however, not modify the default NewForm.aspx page. You can only safely modify it if your feature deploys a dedicated one for the list. More info @ http://msdn.microsoft.com/en-us/library/dd583142(office.11).aspx
Lars Fastrup
Ryan: Well, I am not even sure it is possible because you do not have any HttpContext in the ItemAdded event because it runs async. in another thread. The ItemAdding event occurs before the item is saved and redirecting at this point might about the request and start the redirect before the item gets saved.
Lars Fastrup