Copied to clipboard

Flag this post as spam?

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


  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 22, 2011 @ 18:05
    Jeavon Leopold
    0

    Usercontrol Wrapper Data Type blank on reload

    I'm sure I'm doing something stupid here!  I have created a usercontrol wrapper data type which works perfectly when the content is valid but if the content is not valid the property is saved blank (if you go to another node and back again), even if it was perviously saved valid.

    Here is my code:

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
    
                    if (!string.IsNullOrEmpty(_umbracoValue))
                        editorSource.Text = _umbracoValue;
    
                }
                else if (IsValid)
                {                
                    _umbracoValue = editorSource.Text;
                }
    
    
            }
    
            #region IUsercontrolDataEditor Members
    
            private string _umbracoValue;
    
            object umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor.value
            {
                get
                {
                    return _umbracoValue;
                }
                set
                {
                    _umbracoValue = value.ToString();
                }
            }

    Can someone please point out what I am doing wrong!

    Thanks!,

    Jeavon

  • Comment author was deleted

    Jul 25, 2011 @ 10:26

    Hey Jeavon,

    I would drop the else if in the page_load and move that to the get of the value property

    get

    {

    return editorSource.text; 

    }

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 25, 2011 @ 10:52
    Jeavon Leopold
    0

    Hi Tim,

    Thanks for replying, my problem is I have some logic checks to perform on the content and if they fail I would like to prevent the content being published but allow save, maybe this is not possible with the wrapper?

    Thanks,

    Jeavon

  • Comment author was deleted

    Jul 25, 2011 @ 10:57

    Well you'll need to move that logic to an event handler on the before publish event and cancel publication if it doesn't meet your check

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 25, 2011 @ 11:13
    Jeavon Leopold
    0

    Ok, thanks, but then I need to know the property alias being used for the data type (which I might not)? I'm thinking I need to use a AbstractDataEditor instead of Wrapper as I can then implement my validation logic in the data type, right?

Please Sign in or register to post replies

Write your reply to:

Draft