Creating Editable Custom widgets

Posted by Community Admin on 04-Aug-2018 09:54

Creating Editable Custom widgets

All Replies

Posted by Community Admin on 20-Jul-2011 00:00

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

Posted by Community Admin on 21-Jul-2011 00:00

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

Posted by Community Admin on 22-Jul-2011 00:00

Thanks man, that was absolutely perfect!

Thanks for the help

Posted by Community Admin on 22-Jul-2011 00:00

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

This thread is closed