More in this section

Forums / Developing with Sitefinity / Custom User Control

Custom User Control

4 posts, 0 answered
  1. D.
    D. avatar
    4 posts
    Registered:
    05 Jun 2008
    02 Jul 2008
    Link to this post
    I would like to ask if it is possible to have a UserControl with multiple GenericContent-s, surrounded by a static HTML, for example:

    <table>
        <tr>
             <td>
                  <sf:GenericContent id="cont1" runat="server" />
             </td>
             ...
             <td>
                  <sf:GenericContent id="contN" runat="server" />
             </td>
        </tr>
    </table>
    where each of the contents can be edited with a separate RadEditor. What has to be done,in general, to implement such a solution?
                       
  2. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    03 Jul 2008
    Link to this post
    Hello D.,

    The Sitefinity page editor supports changing properties of any controls that you add from the toolbox. If you create a user control such as the one you want, you would only be able to change its properties, and not the properties of the Generic Content inside it. This in fact means that you have to create custom logic to be able to edit those Generic Content controls in RadEditor.

    I'm not really sure what is the advantage you are trying to achieve through this implementation. If the only reason for doing this is UI (how these GCs are rendered on the page), then you can create a nested masterpage which would contain those 2 Generic Content controls and include the static markup in the child master, all the rest markup for the page being in the parent master. In this way you would be able to edit both GCs with RadEditor and the only disadvantage is one more drag-n-drop operation to place the controls on the page.

    If you have another reason for using such a user control, then please explain in more detail what you are trying to achieve, so that we can help you better.

    Regards,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. D.
    D. avatar
    4 posts
    Registered:
    05 Jun 2008
    03 Jul 2008
    Link to this post
    Actually we are making a migration from another CMS to Sitefinity. We already have some master pages which are used for several templates. The problem is that before that these templates were editable and we were able to insert our own html, add other controls and so on. Now we trying to make these templates like user control, that’s why I am asking about this. Actually we are trying to make a custom property to second a GenericContainer control, which opens a RadEditor, but this way of work is different than the old one from a client’s point of view. So I am asking for this to understand if there are such possibilities.
  4. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    07 Jul 2008
    Link to this post
    Hello D.,

    We could not understand from your post why you took this design decision. I assume that this is the easiest way for you to migrate your project.

    If you ask if it is possible, my answer is yes. Apart from the things I said in my previous post, I would say that the most elegant way to do it would be to create the user control, and then write a custom designer for it. Designers are the controls used to modify how other controls in Sitefinity pages behave. Basically what you need to do is instruct the CMS that the two Generic Content instances in your new control would be edited by RadEditor.

    You can learn more from our new Developer manual and decide if this suits your needs.
    Belows are some links to the relevant sections:

    http://www.sitefinity.com/help/developer-manual/control-designers-overview.html
    http://www.sitefinity.com/help/developer-manual/setting-up-control-designers.html
    http://www.sitefinity.com/help/developer-manual/adding-new-user-controls-implementing-control-designers-on-user-control.html

    Greetings,
    Slavo
    the Telerik team

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