Hi I'm writing an event to User Information List...
Here I'm using some conditions. If they are not met then I have show up an error message and stop the event to complete
in the below code I'm using the ItemUpdated Event of the list. In custom code a condition is checked if satisfies then error page should come....
public override void ItemUpdated(SPItemEventProperties properties)
{
CustomCode(properties);
}
void CustomCode(SPItemEventProperties properties)
{
if (alreadyExist){
alreadyExist =
false;properties.ErrorMessage =
"error message";properties.Cancel =
true;}
Now when I run the above code this message is not coming.....my code is working but it is not opening any error page it directs the user to User Information List......
Please Help...
Thanks
Manu

Help Required- List Events
MigiTheGuru
Hi Ishai read your blog....
Also added my comment there.....
So what I have thought now is that when user is adding something I will use the "ItemAdded" Event to check that it is valid entry.....as this is asynchronous event I can not show Error Page.....Now what I have thought is
I will delete the added item and then show a Message Box
My problem is I can not find Message Box kind of thing in sharepoint...I'm creating a DLL for the Event Handler......Also I have never worked in web scenario ever before. Please Help.
Thanks
Manu
blanc0
I m facing the same issue. Were you able to fix this issue
cgn
Hi Ishai,
I was able to do this using afterproperties in Updating event...but the adding event was giving null values for the Adding Event...
Am I doing something wrong
Thanks
Manu
obelix40
I can not get my custom ErrorMessage to display on my ItemUpdating event. I can cancel the event but all I get is the generic sharepoint error page.
IamHuM
If you read my blog (or search google for itemadding) you will find that this is one of the things that really annoyed me in the last year.
I talked to microsoft, and it's by design - you cant get item properties or access the item in ItemAdding. it's because the item does not exist yet.
HPD
Yes!
Notice that you have BeforeProperties and AfterProperties - these show you the properties before the change and after the change. so you should check these collections instead of checking the item itself.
ItemUpdating(SPItemEventProperties properties)
{
string newTitle = properties.AfterProperties["Title"];
}
nativecpp
Thanks Ishai,
I have somehow adjusted my code in Updating and updated to achieve what was intended.....:)
Thanks alot for all the cool help u gave to me....hope to be in touch.....thanks
-Manu
Olle SW
No i was not.
sorry
PugV
Manu,
The "ItemUpdated" event is asynchronous - meaning it traps the event after it happened (thats why it's called "updated").
To do what you want, you have to override "ItemUpdating" which is syncronous.
Happy to help!
silentC
Manuk,
Remember - asynch handlers like ItemUpdated are happening after the user clicked ok, and have been redirected to another page, and maybe the user even had time to click on another link. When you are in ItemUpdated, there is no user infront of the application.
My idea was to send an email to the user letting him know.
By requiring approval, you can put all your code into ItemUpdating - and there you can show an error to the user since it's synchronous. I used that in my solution (luckily we wanted approval proccess anyway)
coolcoder
akilhoffer26386
Hi
thanks for the advice...but...
I have already tried with Updating event....but the problem is.....the event is attached on my custom list and that custom list has custom fields....
noe in the event I'm checking for the value of those fields....in Updating event....the values are not the the ones which I need to check they are those which were last saved...
any workaround for this
Thanks
Manu