Copied to clipboard

Flag this post as spam?

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


  • James Ward 8 posts 28 karma points
    Nov 18, 2010 @ 02:58
    James Ward
    0

    Member.BeforeSave cancel argument not working

    Hello all.

    Still relatively new to Umbraco but having fun so far!

    Having an issue when attempting to implement some custom validation into the membership section. I have created a method for Member.BeforeSave and have determined it successfully gets called by placing a log call in there.

    The problem I am having however is that when I set the action to cancel it saves regardless. Even when including a call for an error speech bubble it simply shows the 'Member saved' bubble again.

    I have used the exact same code for Document.BeforeSave and it works perfectly. No saving. My custom speech bubble shows.

    Code below.

    Many thanks.
    J.

    public class MemberValidation : ApplicationBase
    {
        public MemberValidation()
        {
            Member.BeforeSave += new Member.SaveEventHandler(Member_BeforeSave);
        }
    
        void Member_BeforeSave(Member sender, SaveEventArgs e)
        {
            ((BasePage)HttpContext.Current.Handler).ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.error, "Manual override", "This node was not saved, deal with it!");
            e.Cancel = true;
        }
    }
    
    public class NodeValidation : ApplicationBase
    {
        public NodeValidation()
        {
            Document.BeforeSave += new Document.SaveEventHandler(Document_BeforeSave);
        }
    
        void Document_BeforeSave(Document sender, SaveEventArgs e)
        {
            ((BasePage)HttpContext.Current.Handler).ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.error, "Manual override", "This node was not saved, deal with it!");
            e.Cancel = true;
        }
    }

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 18, 2010 @ 08:38
    Richard Soeteman
    1

    Did you update a property of the member? Member and document properties are saved when you set them. Check out this blogpost what describes that.

    Cheers,

    Richard 

  • James Ward 8 posts 28 karma points
    Nov 18, 2010 @ 08:40
    James Ward
    0

    I did come across that after I posted however the change I made was through the Umbraco GUI, I imagine that may not make a difference though.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 18, 2010 @ 09:12
    Richard Soeteman
    0

    There was an Improvement on V4.5.x that fixes this behaviour for Document types, apparently not for Members.

    Cheers,

    Richard

  • James Ward 8 posts 28 karma points
    Nov 18, 2010 @ 09:16
    James Ward
    0

    :) Read this one too, it does look that way, I've a workaround for it so it's no biggie but thought it was about time I made some presence on the forums, thanks for your replies.

    I was starting to get into the bad habit of contacting Lee [Kelleher] directly as we're friends from our previous job.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Nov 18, 2010 @ 09:29
    Richard Soeteman
    0

    Nice that you have a work around and its always better to use the forum so people can search for potential answers (and Lee gets some work done ;-) ).

    Cheers,

    Richard

  • James Ward 8 posts 28 karma points
    Nov 18, 2010 @ 09:36
    James Ward
    0

    Well I say habit, it's been twice now but I keep having to say to myself 'Forum first, is what it is there for' as I'm picturing emailing him :P

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Nov 18, 2010 @ 11:35
    Aaron Powell
    0

    Yeah if i needed to capture if I'd create my own Member provider and then run a custom eventing model.

  • James Ward 8 posts 28 karma points
    Nov 18, 2010 @ 11:36
    James Ward
    0

    Thanks guys

Please Sign in or register to post replies

Write your reply to:

Draft