return custom error message after cancel a server side event (C#)

return custom error message after cancel a server side event (C#)

shuminliushuminliu Posts: 14Questions: 6Answers: 0

On the server side I check if a record can be removed. if not I'd like to return a custom error message to the user to explain why it can't be deleted:

editor.PreRemove += (sender, e) =>
{
if (CannotBeDeleted(...))
{
e.Cancel = true;
return;
}
}

I'm wondering where I can add the message like "This record is a special one that you have to keep".

Thanks!

Shumin

Answers

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin

    Hi Shumin,

    Use a validator rather than event handler if you want to return a message to the client-side.

    As the docs mention:

    please note that this is not a replacement for validation - no error will be shown to the end user if the processing of a row is cancelled!

    That said, there probably should be a mechnaisim for feedback rather than just nothing happening. I will look at that in future, but for now, use a validator.

    Allan

  • shuminliushuminliu Posts: 14Questions: 6Answers: 0

    Got it. Thanks!

Sign In or Register to comment.