More in this section

Forums / Developing with Sitefinity / Textarea in control

Textarea in control

2 posts, 0 answered
  1. James@Nw
    James@Nw avatar
    265 posts
    Registered:
    05 May 2009
    04 Jun 2010
    Link to this post
    Hi Guys,

    I know that I cannot use a ContentPLaceHolder in a control so what I need is to be able to create a control and then when the person drags and drops that control onto a page and clicks on the properties of that control, they need to be able to see a textarea box which they can use to populate the content with.

    Have you got a very simple example of somethig like this please?

    Thanks
    James

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jun 2010
    Link to this post
    Hello James,

    You need to create a custom control with ControlDesigner. When you open the ControlDesigner you will see a TextBox where you can enter the text. Then when you close the ControlDesigner the text will be rendered on your page.

    sample code

    control

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Web.UI;
    using Telerik.Framework.Web.Design;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
     
    [ControlDesignerAttribute("SampleControlDesigner, App_Code")]
    public class SampleControl : SimpleControl
    {
        public SampleControl ()
        {
        }
     
     
        [System.ComponentModel.Category("Content")]
         public string EditorContent
         {
     
             get
             {
                 return this._EditorContent;
             }
             set
             {
                 this._EditorContent = value;
             }
         }
     
        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        {
            //
        }
     
        public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
        {
            //
        }
     
         protected override void InitializeControls(System.Web.UI.Control controlContainer)
         {
             base.InitializeControls(controlContainer);
             if (Page == null || DesignMode)
             {
                 Label noDesignModeLabel = new Label();
                 noDesignModeLabel.Text = "NoDesignMode";
                 this.Controls.Add(noDesignModeLabel);
             }
             else
             {
                 Literal showsContent = new Literal();
                 showsContent.Text = EditorContent;
                 Controls.Add(showsContent);
             }
         }
        
        private string _EditorContent;
    }


    control designer

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
     
     
    public class SampleControlDesigner : Telerik.Framework.Web.Design.ControlDesigner
    {
        public SampleControlDesigner()
        {
     
        }
     
        public override string LayoutTemplatePath
        {
            get
            {
                return templatePath;
            }
        }
     
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
     
            ContentTextBox.Text = ((SampleControl)DesignedControl).EditorContent;
        }
     
        public override void OnSaving()
        {
            base.OnSaving();
            ((SampleControl)DesignedControl).EditorContent = ContentTextBox.Text;
        }
     
        public TextBox ContentTextBox
        {
            get
            {
                return base.Container.GetControl<TextBox>("TextBox1", true);
            }
        }
     
     
        private string templatePath = "~/CustomControls/DesignerTemplate.ascx";
    }


    template

    1.<asp:TextBox runat="server" TextMode="MultiLine" MaxLength="1000" ID="TextBox1" Width="600" Height="400"></asp:TextBox>


    Another option is creating  a custom WebUITypeEduitor which open a dialog when a single property has been clicked.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered