More in this section

Forums / Bugs & Issues / Creating Editable Custom widgets

Creating Editable Custom widgets

4 posts, 0 answered
  1. Peter
    Peter avatar
    30 posts
    Registered:
    08 Dec 2010
    20 Jul 2011
    Link to this post
    Hi there,

    I'm looking to create a custom content widget that is editable for the user and Im not really sure which approach to take. At the moment I have created a user control and added it to the toolbox, but when I click on edit, I dont have the option to add my content. How do go about this? I attached a picture of the end product for clarity. Essentially, the user should be able to edit the text but leave the underlying styling and functionality alone.

    Thanks!

    Peter
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    21 Jul 2011
    Link to this post
    Hi Peter,

    What you want to create is a User Control. Here's a way to create a simple User Control:

    In the .ascx file of the control, for example put this:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SimpleControl.ascx.cs" Inherits="SitefinityWebApp.UserControls.SimpleControl" %>
    <p>    Here is some text:    <asp:Label ID="Label1" Font-Bold="true" runat="server" /></p>

    In the .ascx.cs file of the control, put this:
    public partial class SimpleControl : System.Web.UI.UserControl
        {
            private string _labeltext;
      
            public string LabelText { 
                get { return _labeltext; }
                set { _labeltext = value; }
            }  
       
            protected void Page_Load(object sender, EventArgs e) 
            
                Label1.Text = LabelText;
            }
        }

    This control gives you the opportunity to add your own text to the control by editing it's LabelText property (When you drag and drop the custom widget (or control) you have created, click Edit and then fill in the LabelText tab, you will see the text you have entered.). You can use this example to edit your own control.
    More information on createing User Controls you can find here:
    http://www.sitefinity.com/40/help/developers-guide/how-to-how-to-create-a-newsrotator-control-creating-the-newsrotator-as-a-user-control-creating-an-empty-user-control.html

    Greetings,
    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
  3. Peter
    Peter avatar
    30 posts
    Registered:
    08 Dec 2010
    22 Jul 2011
    Link to this post
    Thanks man, that was absolutely perfect!

    Thanks for the help
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    22 Jul 2011
    Link to this post
    Hi Peter,

    You're welcome! Thanks again for using our services.

    Greetings,
    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
4 posts, 0 answered