OK - I dunno how  I missed that - thanks ! But. now I've updated the
code I cannot get the value that has been changed.
Code is below, but the Console.WriteLine() methods all return the value
that is loaded from the document. I would have expected the
NewParent.Value to return the value that it is to be changed to -
otherwise how do you access the value that it is being changed to.
Nothing on docs/google seem to indicate this.. just how to display on
NodeChanged.

            //Create the event handlers.
            doc.NodeChanging += new
XmlNodeChangedEventHandler(this.MyNodeChangedEvent);

..
      // Handle the NodeChanged event.
      public void MyNodeChangedEvent(Object src, XmlNodeChangedEventArgs
args)
      {
            Console.WriteLine("OrderID being updated with value " +
args.Node.Value);
            Console.WriteLine("OrderID being updated with value " +
args.NewParent.Value);
            Console.WriteLine("OrderID being updated with value " +
args.OldParent.Value);
            Console.WriteLine(args.Action.ToString());

            try
            {
                  int newid = Convert.ToInt32(args.Node.Value);
                  Console.WriteLine(" with value  {0}",
newid.ToString());
            }
            catch
            {
                  throw new Exception(args.Node.Value + " must be an
integer value");
            }
      }

-----Original Message-----
From: Stefan Holdermans [mailto:[EMAIL PROTECTED]]
Sent: 12 August 2002 16:45
To: Steven Livingstone; 'Moderated discussion of advanced .NET topics.'
Subject: Re: XmlNodeChangedEventHandler

Steven,

The NodeChanged event is raised when the mutation of the node is
completed: by then, you cannot cancel the mutation by throwing an
exception in the event handler. To prevent the mutation, you should
handle the NodeChanging event instead: throwing an exception here,
prevents the node from actually be mutated.

HTH,

Stefan


You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to