.NET server side cancel some events

.NET server side cancel some events

shuminliushuminliu Posts: 12Questions: 5Answers: 0

I'm using the .NET Editor. I'm trying to only allow users to read and update provided records and don't want them to create or delete. I know on the client side I could do a few things:
(1) not provide the Create and Remove buttons;
(2) Listen to editor.on( 'preCreate/preRemove' and return false to cancel them;

Is there any way I can cancel the two events on the server side?

editor.PreCreate += (sender, e) => {
......
};

Thanks!

Replies

  • shuminliushuminliu Posts: 12Questions: 5Answers: 0

    I ended up with using the request object directly:

    if(request.Form["action"].Count > 0)

    that means the user is trying to do a create/edit/remove; I can get the action from request.Form["action"][0], and then I just return Json(Ok("")).

    I'm still wondering if there is another way.

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    Hi,

    Yes indeed you can cancel the pre events triggered by our .NET libraries. The docs for that are available here.

    editor.PreCreate += (sender, e) => {
      e.Cancel = true;
    };
    

    should do it.

    Regards,
    Allan

This discussion has been closed.