More in this section

Forums / Developing with Sitefinity / Radeditor for generic content meta data?

Radeditor for generic content meta data?

4 posts, 0 answered
  1. Adam
    Adam avatar
    7 posts
    Registered:
    12 May 2008
    13 May 2008
    Link to this post
    I have a module that extends generic content and would like to store html in meta data.  I've tried changing the textbox to a radeditor in the control panel, but the cms provider does not seem to recognize the content/html property.  It also throws a security exception for unsafe data if I try to add html through a textbox and I would like to keep my validations on.  Is there a way to use a RadEditor to edit metadata for generic content? 

    Thanks,
    Adam
  2. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    14 May 2008
    Link to this post
    Hello Adam,

    Yes, there is a way to do this. First, let me give you some background.

    Since all meta fields are automatically saved and set by Sitefinity, there must be some procedure how Sitefinity can do this automatically. The logic goes like this: Sitefinity looks for all controls that have id of a meta key and that can be cast to ITextControl interface. The importance of ITextControl interface is that it mandates the control to have a text property, so Sitefinity always knows that the value of meta field will be stored in controls Text property, without actually worrying what kind of a control it is.

    Your problem is that RadEditor does not implement ITextControl interface and here is the solution:

    1. Create a user control.
    2. Drag RadEditor control on the User Control.
    3. Implement ITextControl interface on the User Control.
    4. Implement mandated Text property on the user control. In the get accessor return RadEditor.Content, in the set accessor set RadEditor.Content to the value.
    5. Replace the textbox with your user control.
    6. Set the id of your user control to the meta key for which you wish to use it.

    I hope you'll find this information helpful. Thank you for getting in touch with us.

    Best wishes,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Adam
    Adam avatar
    7 posts
    Registered:
    12 May 2008
    14 May 2008
    Link to this post
    Ivan,

    Thank you!  It worked like a charm

    Regards,
    Adam
  4. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    15 May 2008
    Link to this post
    Hi Adam,

    I am glad you like the solution. Let us know if there is anything else we can do for you.

    Kind regards,
    Ivan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
4 posts, 0 answered