Copied to clipboard

Flag this post as spam?

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


  • rasb 162 posts 218 karma points
    Apr 23, 2009 @ 00:02
    rasb
    0

    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

  • Richard Soeteman 3875 posts 12037 karma points MVP
    Apr 23, 2009 @ 09:31
    Richard Soeteman
    0

    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

  • rasb 162 posts 218 karma points
    Apr 23, 2009 @ 16:41
    rasb
    0

    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

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    May 25, 2009 @ 10:13
    Hendy Racher
    0

    Hi rasb,

    Did you ever find a way of getting a WebControl from a DataType using the API ?

    Thanks,
    Hendy

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    May 25, 2009 @ 13:07
    Hendy Racher
    0

    incase anyone finds this useful : For a known DataTypeDefinition

    Control propertyField = dataTypeDefinition.DataType.DataEditor.Editor;

  • 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