Copied to clipboard

Flag this post as spam?

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


  • Simon 81 posts 184 karma points
    Jul 26, 2012 @ 15:03
    Simon
    0

    problem with media picker in custom section

    Hi all,

    I've been bashing my head against this now for about a day - all I want to do is have a media picker on a custom section. The page loads fine without the Picker on it, so I know it's something to do with the control. I've followed 

     

    on my ASPX page I have:

    <asp:PlaceHolder ID="pickerPlaceHolder" runat="server"></asp:PlaceHolder>

    then in code-behind file I have:

    class MediaPickerDataExtractor : IData
    {
        private object _value;
        public MediaPickerDataExtractor() { }
        public MediaPickerDataExtractor(object o)
        {
            Value = o;
        }
        #region IData Members
        public void Delete()
        {
            throw new NotImplementedException();
        }
        public void MakeNew(int PropertyId)
        {
            throw new NotImplementedException();
        }
        public int PropertyId
        {
            set { throw new NotImplementedException(); }
        }
        public System.Xml.XmlNode ToXMl(System.Xml.XmlDocument d)
        {
            throw new NotImplementedException();
        }
        public object Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }
        }
        #endregion
    }

    Then I have at the top of my page class:

    private umbraco.editorControls.mediaChooser _mediaPicker;
    private MediaPickerDataExtractor _mediaPickerExtractor;

    Before finally in the OnInit function:

    _mediaPickerExtractor = new MediaPickerDataExtractor();
     _mediaPicker = new umbraco.editorControls.mediaChooser(_mediaPickerExtractor, true, true);
     _mediaPicker.Value = "";
    //_mediaPicker.ID = "mediapicker";
    pickerPlaceHolder.Controls.Add(_mediaPicker);
    base.OnInit(e);

    Custom section is registered fine, but when I click on the page, I get the following:

    [NullReferenceException: Object reference not set to an instance of an object.]
       umbraco.editorControls.mediaChooser.CreateChildControls() +136
       System.Web.UI.Control.EnsureChildControls() +102
       MPUManagementPage.OnInit(EventArgs e) +197
       System.Web.UI.Control.InitRecursive(Control namingContainer) +140

    Does anyone have any ideas?

    Many thanks

    Simon

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies