More in this section
Forums / Developing with Sitefinity / Best way to create custom "Content" controls

Best way to create custom "Content" controls

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Andrew Ryan
    Andrew Ryan avatar
    3 posts
    23 Apr 2009
    04 Jan 2010
    Link to this post
    I just finished reading the article in your documenting about Extending Telerik Controls - but I still don't know the answer to my question.

    I have a site where I want to let the user specify some custom content for announcements - almost like the Generic Content Control. The problem is, I need this content to be contained in a div element with a CSS Class that displays a gray header bar in the content. Also - I need to let the user specify a "title" for the content - this title is displayed above the text.

    But I love the generic content controls RadEditor interface - that's what I want. But I need to adda Title field and change the rendering a little bit to add the div tag.

    There are 5 ways to skin this cat - what's the best?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    05 Jan 2010
    Link to this post
    Hello Andrew Ryan,

    You can create a custom control that derives from GenericContent class. Then you have to create a public property in the GenericContent designer where you will enter the text for your content, since the RadEditor content area will be used to enter the content. You can add the css to the ContentPlaceHolder of the RadEditor control or just ApplyCss to the RadEditor content.

    In your custom designer you have to create a property which will be used to set the Title. Here you have to override InitializeControls method which is uses to get the data when you open the designer.

    Title.Text = ((CustomGenericContent)DesignedControl).GenericContentTextBox.Text;

    You also have to override OnSaving() to persist the property value.

    In the custom control that derives from GenericContent you have to override Render method and set the GenericContentTextBox.Text to the text you have entered in the designer.
    You can use shared content as well which will allow you to work with metadata. You may find the following KB useful - Wrap Generic Content control in Sitefinity 3.6 ( the same applies for 3.7)

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered