Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • greengiant83 88 posts 109 karma points
    Mar 18, 2011 @ 16:49
    greengiant83
    0

    Cancel save/publish event if validation fails

    I have a custom data type (a usercontrol implementing IUsercontrolDataEditor) and I would like to enforce validation on save/publish.  Is there a way to cancel the save/publish event on the client side if my custom validation logic fails?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 18, 2011 @ 17:14
    Jan Skovgaard
    0

    Hi Greengiant

    What is the datatype doing? I suppose you might could use some JavaScript dependent on what your datatype does etc....could you ellaborate a bit more on what your datatype is doing?

    /Jan

  • greengiant83 88 posts 109 karma points
    Mar 18, 2011 @ 18:27
    greengiant83
    0

    Jan,

     

    I dont need help writing the validation logic. I need to know where to hook code in to cancel the save/publish event if the entered data is no good.  For the sake of discussion, lets say I have a color picker that needs to validate that the choosen color is close to a specified pallete of colors.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 18, 2011 @ 19:29
    Tom Fulton
    1

    Hi,

    I'm not sure you can cancel a save/publish event from a datatype itself.  I know you can do it from an Event Handler using e.Cancel = true;

    But, I do think you can add a ValidationProperty to your datatype in 4.7+ that might help.  See this thread:  http://our.umbraco.org/forum/developers/extending-umbraco/14157-Make-custom-datatype-mandatory

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft