Anybody used the "ItemAdding" method successfully in an Event Receiver in Sharepoint for validation?

I think it just can't work properly for validation purposes because it seems that :

  • You can't access the data you just entered in a form
  • If you add an error message, instead of displaying the form back with your error, Sharepoint
    display the big ugly error page.

Here's what I found so far on the web for the ItemAdding method :

Anyway, if somebody successfully used that method, please tell me how because I think that it's just broken/missing something!


+2  A: 

You can't use ItemAdding to perform that kind of "friendly" validation checking. If you set e.Cancel = true and set e.ErrorMessage, sharepoint will redirect you to the standard error page and display your message. You can't make it redirect back to your form page.

Rather than trying to hack the built in pages, you should use an infopath or aspx form bound to a content type. Infopath has built-in validation controls and with aspx forms you build yourself you can treat it like any web app and choose your own validation.

No easy way out here I'm afraid.



Having same issue. Plz reply if somebody have a answer. Thank in advance, Hiral