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

Forums / General Discussions / Building a widget for 4.2 - what is the most up to date example?

Building a widget for 4.2 - what is the most up to date example?

4 posts, 0 answered
  1. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    18 Aug 2011
    Link to this post
    I am building a simple widget for Sitefinity 4.2 toolbox based on a user control that includes a widget designer so a back end user can configure the widget.

    Can anyone point me to the most up to date example (meaning 4.2 compatible) or documentation of building a widget for the toolbox?

    I've built some widgets for 4.0 and 4.1, but I want to make sure that I'm following the very latest best practices.

    Thank you,
    Dan Sorensen
    Vancouver, WA
  2. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    18 Aug 2011
    Link to this post
    I'm still mainly looking for current documentation as stated above, but to clarify why I'm looking for it, here are the current steps I follow to create a custom widget. Is this way still recommended? Are there any alternate or easier ways?

    Task: create a widget that outputs a copyright symbol and the current year and a user provided string such as "copyright [our company], all rights reserved."

    Purpose: To always have an up to date year in our copyright message in the footer of user designed templates.

    Steps:
    1. In Visual Studio - create a new folder for the widget
    2. Create Widget.ascx & the codebehind Widget.ascx.cs
    3. Add my code to create the widget.
    4. Create WidgetDesigner.cs - add some boilerplate Sitefinity designer code
    5. Create WidgetDesigner.js - add some boilerplate Sitefinity designer js code
    6. Create WidgetDesignerTemplate.ascx - add some boilerplate Sitefinity html
    7. Compile
    8. Register the widget (user control) in Administration > Advanced > Toolbox
    9. Test via the user back end screens and hope I didn't break anything too badly.

    If that is still correct, I'm ok. Although, I wish that steps 4-6 were more straight forward. The boilerplate code is pretty verbose and difficult to work with other than copy/paste, rename a couple variables to match my user control's name and properties.

    Step 8 works fine, although it's never easy to remember what needs to be typed in there. Can this be done with a config file instead?

    For step 9, I wish there was a standalone simplified sitefinity page project that I could load my custom widget into simply for testing. A project that did nothing other than display a sample page for testing widgets. It takes a long time to navigate to a page for testing.
  3. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    18 Aug 2011
    Link to this post
    It looks like the 4.2 developer documentation does have quite a bit on the topic: 
    http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-controls-working-with-control-designers.html

    If you have more sources, I'm interested in reading some examples. I'm sorry if I wasted anyone's time. In 4.0 I had to track down the information in a blog article somewhere rather than in the Sitefinity Docs. I had assumed that was still the case.
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    23 Aug 2011
    Link to this post
    Hi Dan Sorensen,

    Thank you very much for the positive feedback, indeed our Documentation has become much more complete and organized with the last two major releases. Along with it I'd recommend you to take a look at the Sitefinity SDK which offers several complete code samples ranging from simple controls to advanced modules. The Tutorials section from our online Documentation is another valuable resource that you might refer to along with the SDK.
    I'd like to comment a little bit on the workflow you have outlined in the previous response - indeed this is the correct way to create a custom control for Sitefinity, however you are not obliged to stick to that format when it comes to some widgets requiring simple functionality. If you are not required to have custom designer for your control, you can still expose some properties in the default one, and end up with a simple user control consisting of a template (*.ascx), codefile (*.cs) and the automatically generated designer(*.ascx.designer.cs)
    and thus skip steps 4-6 . Say for instance our NewsRotator sample is a good example of a Sitefinity widget that does not require custom designer. If there's anything else you'd like to know, please do not hesitate to ask.

    Regards,
    Boyan Barnev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

4 posts, 0 answered