MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Displaying custom error in event handler - Sharepoint 2007

  Asked By: Rocco    Date: Jun 15    Category: MOSS    Views: 2695

I have written a code for event handler ('ItemAdding') for a list.
I want to display the custom error message. I am using the following
code for the same

properties.ErrorMessage = "some xxx";
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;

It is working fine, but the error message is displaying in a new
page. I want to display the error message in the same page instead of a
new page.

Is it possible to display the error message in the same page? If it is
possible please suggest the steps to achive the same.



3 Answers Found

Answer #1    Answered By: Octavio Dotson     Answered On: Jun 15

The ErrorMessage property of the event  handler always displays on a custom  error
page. You might be able to display an error  on the current page using some kind
of Javascript, but it would have to be all custom code.

Answer #2    Answered By: Judy Pittman     Answered On: Jun 15

I have yet to find a way to display the message on the same page from the event
handlers. If you find something out, please let me know. What I did, was at
the end of each error  message, I added the following text: "To correct this
error, press the Back button." This at least prompts the user on what can be
done to fix the error.

SharePoint is an absolutely terrific product, but this is one of my pet peaves.

There may be times where you can do error handling in a custom  field type. This
will show the column error on the same page. The following URL has an example
of a field type with editing:

Answer #3    Answered By: Tricia Mullins     Answered On: Jun 15

I have one more question
Can we able to add anchor tag(<a href=''></a>)in the error  message to redirect
user from error page to previous page.

Didn't find what you were looking for? Find more on Displaying custom error in event handler - Sharepoint 2007 Or get search suggestion and latest updates.