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

Forums / Developing with Sitefinity / ControlDesigner example

ControlDesigner example

6 posts, 0 answered
  1. Clyde
    Clyde avatar
    15 posts
    Registered:
    02 May 2008
    30 Sep 2008
    Link to this post

    I have created a few custom controls, and they all work fine. As a final step I would like to add designer support so they render correctly at design time. I can get the instance of my control in the designer, but it appears that the properties (such as template name) have not been restored yet and these are required to render it accurately.

    Does anyone have a good example of how to create an appropriate ControlDesigner class for a custom control running under SiteFinity?

  2. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    30 Sep 2008
    Link to this post
    The Sitefinity team just added a topic to the Sitefinity developers manual on Control Designers and Implementing Control Designers.

    Joseph Guadagno
    Southeast Valley .NET User Group
  3. Clyde
    Clyde avatar
    15 posts
    Registered:
    02 May 2008
    30 Sep 2008
    Link to this post

    I did look at that but I think it is a different issue. That example is providing a control to do detailed editing of the controls properties - after you mouse over and select 'Edit'.

    What I am trying to do is to have the control render correctly when the page is in edit mode. Right now, without a control designer I get some strange message about 'Index out of bounds' in place of the control while editing. This seems to be using a similar model to Visual Studio edit in that the ControlDesigner is created to handle presentation of the underlying control.

    I have added the Designer attribute to my control and the Designer class is being called to render but, when I get the actual control (it is the component during edit) it has not been initialized by SiteFinity and the properties which are persisted by the framework have not been set.

  4. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    30 Sep 2008
    Link to this post
    Hi Clyde,

    Control Desigers are a way to customize what is displayed when you click the "Edit" link. 

    It sounds like this isn't your issue though.  It sounds like you're dragging your custom control onto a Sitefinity page and getting an error in preview mode.

    For some of the custom controls I've created, I've had to be very careful about assuming my variables are set.  In some cases I've set default values for my variables.  In other cases I needed to test for "null" values:

    if (this.CustomProperty != null)   {
          // Do something, but avoid if variable is not set
    }

    The error you mention sounds like you might be trying to use a variable that isn't set to anything.  Please let me know if I'm wrong or not understanding correctly.

    Gabe Sumner

  5. Clyde
    Clyde avatar
    15 posts
    Registered:
    02 May 2008
    01 Oct 2008
    Link to this post
    You are correct, I am using one of my own custom control on the page. The problem I have is that the value stored in one of the properties (the template location) is normally saved/restored by the SiteFinity framework automatically. In design mode however, it does not appear that these properties are being restored automatically, so I can not properly render the control.

    I'm looking to see if their is either some way to have SiteFinity set these properties in design mode or, is there some way fof me to manually access them through some other admin classes.
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    03 Oct 2008
    Link to this post
    Hello Clyde,

    Could you please refer to the Dev.Manual article Create control designers and more specifically in the method:
    base.OnPropertyChanged(); 

    Please make sure it is implemented the way we have done it.
    If you prefer, we could take a look in your control and see what might be wrong. If you decide so, please open a support thread and attach your control to it.

    Kind regards,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
6 posts, 0 answered