Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
i'm currently working on something for which i need the before and after state of a property's value (Document.Text aka name) for a rename operation.
i've looked at the Document.AfterSave/BeforeSave events but they seem to give only the currentstate.
So is there anyway to access both value states of Text in these events or in the AbstractDataEditor.DataEditorControl.onsave?
Yes, it is possible and I am doing it right now.
Basic idea is that you subscribe to two events: Document.BeforeSave and Document.AfterSave. First event (BeforeSave) fires with sender document version that is "old" and second event (AfterSave) fires with "new" version. Then you can use "old" version to fetch data from database and update it with "new version".
Here I have some code:
Document.BeforeSave += Document_BeforeSaveHandler;
Document.AfterSave += Document_AfterSaveHandler;
private void Document_BeforeSaveHandler(Document sender, umbraco.cms.businesslogic.SaveEventArgs e)
// save sender in class field or something, call it beforeSave.
private void Document_AfterSaveHandler(Document sender, umbraco.cms.businesslogic.SaveEventArgs e)
// save sender in class field, call it afterSave.
// then you can do something like
// and maybe set beforeSave = null; and afterSave = null;
That is roughly what I do and it works really well for me :)
Maybe you want to read this topic: http://our.umbraco.org/forum/developers/extending-umbraco/25925-Catch-Change-Of-Property-Value-In-Event.
I also think it's important to read this topic: http://www.aaron-powell.com/the-great-umbraco-api-misconception.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted