4

I have a problem with displaying error messages inline, but sharepoint displays that ugly yellow page. Yes the error message is correct, it's the one I defined but I need to display errors like the picture below, inline.

Now I got error like this.

enter image description here

and I want to display it right here. I know it's possible but couldn't figure it out.

enter image description here

and here is my code

public override void ItemAdding(SPItemEventProperties properties)
{
    base.ItemAdding(properties);
    ...
    ...
    if (mycondition)
    {
        properties.Status = SPEventReceiverStatus.CancelWithError;
        properties.ErrorMessage = "Staff not found, check staff number and try again.";
    }
}

I'm pretty sure this code was working before but now displays that ugly page. What should I do to fix it?

EDIT 1 There are some other lists that event receivers work as expected and error is displayed in the form page. This particular list that I'm having trouble was deleted and imported from a file exported from another sharepoint machine. I believe after import this problem occurred.

EDIT 2 Ok here it is. This is a subsite and a dummy custom list usin existing event receiver. This event receiver runs on every custom list named Staff on any site. Here it displays the error message on the form page which is what I want. I can't delete my actual custom list that is having problem because in the future I'll use import functionality to import list and need to fix it without deleting/recreating it.

enter image description here

EDIT 3 Ok found the problem, if I add an existing column "Rollup Image" on submit page starts to give that ugly .net error page. Now we know what's causing trouble, how can I fix that?

2
  • updated my question providing more info
    – Ergec
    Apr 1, 2015 at 17:23
  • Event receiver runs at server-side, so it is not best idea if it breaks sharepoint logic and remains on this form with error message(by default sharepoint redirects from this form).
    – Gennady G
    Apr 1, 2015 at 18:21

1 Answer 1

0

Imho the page looks ugly, becouse detailed errors messages are enabled. Change web.config options back to turn it off, and it will show "standard" sharepoint error page with Your message. In my case if I want to display customized error message to user, I create Page and redirect to it from event receiver.

4
  • Actually like I said, before import, it was already displaying error message where I marked as red. Then something happened after I imported the list and suddenly error page started to appear.
    – Ergec
    Apr 1, 2015 at 18:22
  • imho the form was customized to show the message, after import it switched to default EditForm, or the form imported incorrectly
    – Gennady G
    Apr 1, 2015 at 18:46
  • no nothing is customized. all standart except an event receiver. I created a dummy subsite and a list and it works there. Updated my question with a screenshot
    – Ergec
    Apr 1, 2015 at 19:31
  • I found the problem, it's rollup image field. Before this field errors are displayed at the bottom of the form. If I add this rollup image field, errors displayed at that ugly NET error page.
    – Ergec
    Apr 6, 2015 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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