I'm currently working on a project where I map a config file against Umbraco controls. Here's How I solved it (must say I still have issues with the TinyMCE control).
As you allready noticed In umbraco.editorControls you can find all the edior controls of Umbraco. You will find a DataType control and a webcontrol. I've used the webcontrol Directly. This is because I have written my own Implementation of the IData Interface which you can pass to the webcontrol. In the examples below I've modified the control a bit to leave the implementation details out.
IData implementation
[code]
public class DBListData : IData
{
#region IData Members
private int propertyID;
private object _value;
public void Delete()
{
//Do nothing
}
public void MakeNew(int propertyId)
{
PropertyId = propertyId;
}
public int PropertyId
{
set { _propertyID = value; }
}
public System.Xml.XmlNode ToXMl(System.Xml.XmlDocument data)
{
return null;
}
public object Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
#endregion
}
[/code]
My control that reference TextStringControl
[code] public class TextstringFormControl: WebControl
{
public TextstringFormControl(FormElement )
TextFieldEditor _textControl;
IData _data = new DBListData();
That works, but I was hoping that there might be an easier way to do it. Not that I mind writing code, but I mind redoing what others have already done much better than I am about to.
I was hoping that there might be some way in the API to get a reference to the WebControl object from the DataType. The way you have outlined here, will still require me to set up some kind of framework for creating the webcontrols and switches to determine what kind of WebControl to create.
Another thing I would like to get is an IData object from the logged in user, so I can display the recorded information about the user.
DataTypeDefinition to umbraco.editorControl
Hi guys,
I am trying to create a registration form that, based on the member type will auto generate the the form.
I can easily create a list of the properties on the membertype:
[code]
MemberType mt = MemberType.GetByAlias(this._memberTypeAlias);
List
Hi,
I'm currently working on a project where I map a config file against Umbraco controls. Here's How I solved it (must say I still have issues with the TinyMCE control).
As you allready noticed In umbraco.editorControls you can find all the edior controls of Umbraco. You will find a DataType control and a webcontrol. I've used the webcontrol Directly. This is because I have written my own Implementation of the IData Interface which you can pass to the webcontrol. In the examples below I've modified the control a bit to leave the implementation details out.
IData implementation
[code]
public class DBListData : IData
{
#region IData Members
private int propertyID;
private object _value;
public void Delete()
{
//Do nothing
}
public void MakeNew(int propertyId)
{
PropertyId = propertyId;
}
public int PropertyId
{
set { _propertyID = value; }
}
public System.Xml.XmlNode ToXMl(System.Xml.XmlDocument data)
{
return null;
}
public object Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
#endregion
}
[/code]
My control that reference TextStringControl
[code] public class TextstringFormControl: WebControl
{
public TextstringFormControl(FormElement )
TextFieldEditor _textControl;
IData _data = new DBListData();
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_data.Value = "MyDefaultValue";
_textControl = new TextFieldEditor(data);
textControl.ID = "MyTextControl";
PropertyPanel umbracoPanel = new PropertyPanel();
umbracoPanel.ID = "umbracoPanel";
umbracoPanel.Text = "Label";
umbracoPanel.Controls.Add(textControl);
this.Controls.Add(umbracoPanel);
}
public override object value
{
get {
_textControl.Save();
return _data.Value;
}
}
}[/code]
Hope it helps you,
Richard
Hi Richard,
That works, but I was hoping that there might be an easier way to do it. Not that I mind writing code, but I mind redoing what others have already done much better than I am about to.
I was hoping that there might be some way in the API to get a reference to the WebControl object from the DataType. The way you have outlined here, will still require me to set up some kind of framework for creating the webcontrols and switches to determine what kind of WebControl to create.
Another thing I would like to get is an IData object from the logged in user, so I can display the recorded information about the user.
Thanks,
rasb
Hi rasb,
Did you ever find a way of getting a WebControl from a DataType using the API ?
Thanks,
Hendy
incase anyone finds this useful : For a known DataTypeDefinition
Control propertyField = dataTypeDefinition.DataType.DataEditor.Editor;
is working on a reply...
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.