Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I developed a custom event receiver class that overrides the ItemAdded method

after the list item is added I want to make some checks and based on a certain condition I want to delete the added item.

I was able to delete the item but i want to display an error message so I used

properties.Cancel = true; 

properties.ErrorMessage = "Can't insert this item";

when I debugged I found no errors but the user is not directed to the error page.

is there any workaround for this ?

thanks

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Since you are using ItemAdded in SharePoint 2007 that event is asynchronous and happening after the item is added. Asynchronous means that it will happen "behind the scenes", ie you cant redirect the user to an error page. Instead try to use the ItemAdding if you need to cancel the event and present an error message for the user.

share|improve this answer
    
Thanks I already know that I want to force a redirection is it possible ? –  Mina Samy Jun 17 '10 at 13:12
1  
You can only force a redirection in the synchronous events. –  Wictor Wilen MCA MCM MVP Jun 17 '10 at 14:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.