Copied to clipboard

Flag this post as spam?

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


  • Jon 17 posts 40 karma points
    Jul 21, 2010 @ 15:10
    Jon
    0

    Forcing a save within custom datatype

    Hi. Apologies if this has been asked before. I had a bit of a search but couldn't find anything.

    I'm writing a custom datatype for one of our solutions. I have my 3 classes set up (one implementing IDataEditor, one for IDataPreValue and one for IDataType) and they're all working fine. What I'd like to know though is if there's a way to force a Save on the content node which contains the data type using the Umbraco API?

    Currently I'm implementing the Save method in the following way:

    public void Save()
    {
      data.Value = FetchDataFromControls();
    }

    However, that only fires when the Save (or Save & Publish) button is clicked on the content node. I'm doing some other processing within my data type but if the end user forgets to hit "Save" after editing the content node, Umbraco doesn't pick up the changes in my control. It would be nice if within my code I could explicitly force a save of the content node within my DataEditor so this does not occur. Is there any way I can achieve this?

     Hope that makes sense. I'm still pretty new to Umbraco but hope I've explained it well enough to make sense.

     Cheers

    Jon

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 21, 2010 @ 15:29
    Lee Kelleher
    1

    Hi Jon,

    Yes, you can set the value property of the data object - it will do an update on the 'cmsPropertyData' database table.  It doesn't need to be used in the Save() method, it can be used anywhere in your data-type.

    data.Value = whatever;

    Cheers, Lee.

  • Jon 17 posts 40 karma points
    Jul 21, 2010 @ 15:36
    Jon
    0

    Awesome - I didn't think that would work but it does perfectly! Thanks Lee!

  • Rune Grønkjær 1372 posts 3103 karma points
    Nov 13, 2012 @ 10:25
    Rune Grønkjær
    0

    Hi guys,

    Is there some method of doing this with a Usercontrol datatype? I mean forcing a save from within the datatype.

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft