ContentPicker in Usercontrol - Value cannot be null
Hi All,
Been trying to create a custom datatype which contains two textbox controls and a content picker.
My starting poiint was the excellent video 'create a custom datatype using the umbraco usercontrol wrapper.' This part works fine. But from here I've added the content picker which is rendering correctly. However when I try and save the page a 'value cannot be null' error is displayed.
The code I have is:
public partial class LinkBox : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor { ContentPicker mp = new ContentPicker();
public object value { get { XDocument values = new XDocument( new XElement("textBoxes", new XElement("textBox", new XAttribute("id", linkText.ID), new XElement("value", new XCData(linkText.Text)) ), new XElement("textBox", new XAttribute("id", linkUrl.ID), new XElement("value", new XCData(linkUrl.Text)) ) ), new XElement("mediaNode", new XAttribute("id", mp.ID), new XElement("value", new XCData(mp.Value)) ) ); return values.ToString(); } set { if (value != null) { try { XDocument savedValues = XDocument.Parse(value.ToString()); IEnumerable<TextBox> textBoxes = linkPanel.Controls.OfType<TextBox>(); foreach (TextBox textBox in textBoxes) { string inputId = textBox.ID; var vstr = (from xml in savedValues.Descendants("textBox") where xml.Attribute("id").Value == inputId select xml).Single().Element("value").Value; textBox.Text = vstr; } IEnumerable<ContentPicker> contentPickers = mediaPickerPlaceHolder.Controls.OfType<ContentPicker>(); foreach (ContentPicker contentPicker in contentPickers) { string inputId = contentPicker.ID; var mvstr = (from xml in savedValues.Descendants("mediaNode") where xml.Attribute("id").Value == inputId select xml).Single().Element("value").Value; contentPicker.Value = mvstr; } } catch (System.Xml.XmlException e) { //No root node element } } } }
#endregion
Would be grateful if someone could point me in the right direction.
ContentPicker in Usercontrol - Value cannot be null
Hi All,
Been trying to create a custom datatype which contains two textbox controls and a content picker.
My starting poiint was the excellent video 'create a custom datatype using the umbraco usercontrol wrapper.' This part works fine. But from here I've added the content picker which is rendering correctly. However when I try and save the page a 'value cannot be null' error is displayed.
The code I have is:
Would be grateful if someone could point me in the right direction.
Thanks,
Eddie
is working on a reply...