TransWikia.com

How to display event receiver error inline not in error page

SharePoint Asked by Ergec on December 10, 2020

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?

One Answer

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.

Answered by Gennady G on December 10, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP