Copied to clipboard

Flag this post as spam?

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


  • Greg 6 posts 26 karma points
    Sep 11, 2012 @ 01:41
    Greg
    0

    Umbraco: mediaChooser in UserControl

    I implemented a media chooser in my own user control data type like so:

    protected override void OnInit(EventArgs e)
    {
       
    base.OnInit(e);

       
    var dataTypeDefinition1 = DataTypeDefinition.GetDataTypeDefinition(1035);
       
    var mediaChooser = (mediaChooser)dataTypeDefinition1.DataType.DataEditor;
        mediaChooser
    .ID = "MediaChooser";
        panel
    .Controls.Add(mediaChooser);
    }

    then I set the value of the media chooser like so:

    protected override void OnPreRender(EventArgs e)
    {
       
    base.OnPreRender(e);

       
    var mediaChooser = panel.FindControl("MediaChooser") as mediaChooser;
       
    if (mediaChooser != null)
       
    {
              mediaChooser
    .Value = myObj.MediaId;
       
    }
    }

    This seems to load everything just fine, and I can open the dialogue to select a new image. However when I select a new image and click the 'pick item' button in the dialogue, the picked image does not make it into the mediaChooser. It still holds the old image.

    No postback occurs or anything. The console in chrome comes up blank.

    I swear this used to work, and just seemed to stop. I don't think anythings changed this end. Any idea's on how I can debug this further?

    Cheers, Greg

  • Greg 6 posts 26 karma points
    Sep 11, 2012 @ 06:11
    Greg
    0

    I traced the javascript, and it put the dialogs return value into the ModalWindow.m_rVal variable, and then the code just closes the window. Is the mediaChooser supposed to pick this change up somehow via the onHide handler?

Please Sign in or register to post replies

Write your reply to:

Draft