1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Layout Template a User Control

Layout Template a User Control

6 posts, 0 answered
  1. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    18 Nov 2011
    Link to this post


    There is a way to template a User Control (not a Custom Control).

    The thing is we have a bunch of standard .NET user controls and want to register them in the toolbox and be able to change the LayoutTemplate using Sitefinity. Is this possible ?

    Thanks in advance for any thought on this.

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    20 Nov 2011
    Link to this post
    Do you just mean this?

    <add tagName="MenuSearchBar" tagPrefix="ocfp" src="~/UserControls/Menu/MenuSearchBar.ascx" />

    If you add it to the web.config with the above line then you can use it in your .master file.

    ...or you can register it in the backend Settings->Toolbox like this
    <add enabled="True" type="~/UserControls/CME/OnTheRoadCalendar/OnTheRoadCalendar.ascx" title="OnTheRoadCalendar" description="OnTheRoadCalendar" cssClass="ontheroadIcon" layoutTemplate="~/UserControls/CME/OnTheRoadCalendar/OnTheRoadCalendar.ascx" visibilityMode="None" name="OnTheRoadCalendar" />
    ...and then it allows you to drag and drop it onto a page dynamically in the page editor :)

    If I've got your question wrong, please let me know :)
  3. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    21 Nov 2011
    Link to this post

    Thanks Steve,,

    Is more complicated than that ... Actually I want to take advantage of some Sitefinity template replacement (engine, core) etc but without having to use Custom Controls...  I far as know custom controls inherit from ViewBase, ContentView etc.
    But "user controls" are simple plain asp net web user controls.

    Can I use template replacement mechanism on out of the box web user controls...? Need to implement some interface for example ITemplate ?

    With template replacement mechanism  I mean be able to change a widget template using the LayoutTemplateName , Virtual Paths ,config .. or whatever.

    Thanks again..
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    24 Nov 2011
    Link to this post
    Hello Ronnie,

     I understand what you need, but I don't think this would be possible. In .ascx controls the view and the code-behind are dependent on each-other, which means that you cannot separate them without making the control a custom one (inheriting from ViewBase), which would separate view and "viewmodel". 

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Ronnie
    Ronnie avatar
    31 posts
    Registered:
    20 Jul 2011
    29 Nov 2011
    Link to this post

    Thanks a lot, that's what I thought...
  6. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    30 Nov 2011
    Link to this post
    Hi Ronnie,

     Glad that we cleared this out. Let me know if you have any other questions.

    Regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered