Cancel Postback in OnClientNodeEdited Event

5 posts, 0 answers
  1. Marbry
    Marbry avatar
    123 posts
    Member since:
    Aug 2012

    Posted 06 Jun 2012 Link to this post

    Is there a way to cancel the postback from the OnClientNodeEdited event handler for the OnNodeEdit server event?  I need to be able to selectively cancel this postback in the client code, but I haven't found a way that works yet.

    There is no set_cancel() in the arguments passed.  Setting cancelBubble and returnValue on the window.event don't work.  Calling node.endEdit() or _cancelEvent() both throw an error.

    I even tried setting the node's _originalText and _originalTextHtml to its _text value to see if it would keep it from being detected as modified.

    Any suggestions would be welcome.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2012 Link to this post

    Hi Marbry,

    You can cancel OnNodeEdit sever side event in the OnClientNodeEditing as follows.

    JS:
    <script type="text/javascript">
        function OnClientNodeEditing(sender, args)
        {
            args.set_cancel(true);
        }
    </script>

    Hope this helps.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marbry
    Marbry avatar
    123 posts
    Member since:
    Aug 2012

    Posted 07 Jun 2012 Link to this post

    Well no, as I stated above, there is no set_cancel() method on the arguments for that handler for some reason.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2012 Link to this post

    Hi Marbry,

    The OnClientNodeEdited event occurs when a node has been edited by the end user. It is not possible to cancel the serverside postback from OnClientNodeEdited event. The OnClientNodeEditing event occurs after the user has finished editing but before the OnClientNodeEdited event. If you want to cancel the postback you can cancel that from  OnClientNodeEditing event as I suggested above. Please take a look into the following documentations for more information.
    OnClientNodeEditing
    OnClientNodeEdited

    Please elaborate your scenario if it doesn't help so that I can suggest a way.

    Thanks,
    Princy.
  6. Marbry
    Marbry avatar
    123 posts
    Member since:
    Aug 2012

    Posted 07 Jun 2012 Link to this post

    Ok, that's what I get for reading that on my phone.

    Yes, I think that's going to work.  Although it does require setting the _originalText properties so that it doesn't just reset the visible node on the client to the previous value.

    Thanks!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017