More in this section

Forums / Developing with Sitefinity / Multiline String Properties?

Multiline String Properties?

6 posts, 0 answered
  1. Paul
    Paul avatar
    24 posts
    Registered:
    16 May 2011
    25 May 2011
    Link to this post
    It's entirely possible that I'm being stupid, but any light you can shed would be appreciated!

    I have created a custom UserControl for the footer of my website. One of the properties of the control is for storing the business address. I originally had this as a simple string property, but when this is displayed in the backend it is shown as a single line textbox. I wanted this to be a multiline textbox (much better for an address field), so changed the property as follows:

    01.namespace SitefinityWebApp.UserControls
    02.{
    03.    abstract public class TypeNames
    04.    {
    05.        // Each constant below should be on a single line
    06.        public const string UITypeEditor = "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    07.        public const string MultilineEditor = "System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
    08.    }
    09. 
    10.    public partial class GTC_Footer : System.Web.UI.UserControl
    11.    {
    12.        private string[] _footerAddress = new string[6];
    13. 
    14.        [Category("General"), Editor(TypeNames.MultilineEditor, TypeNames.UITypeEditor)]
    15.        public virtual string[] FooterAddress
    16.        {
    17.            get
    18.            {
    19.                return this._footerAddress;
    20.            }
    21.            set
    22.            {
    23.                this._footerAddress = value;
    24.            }
    25.        }

    When I go to edit the property in the backend, rather than a single line textbox it displays a button that when clicked opens another dialog window to edit the property. However, there is still no multiline textbox, but what appears to be more properties of the field (see attached screenshot).

    Any ideas how to get a multiline textbox instead?

    Help would be much appreciated!

    Paul
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 May 2011
    Link to this post
    Hi Paul,

    I think the best approach here would be to create a custom control designer for your control. There you can define the interface for editing your widget. You can find a tutorial on the creation of control designers here. I have also attached a quick sample user control with two text fields, one using the rich text editor.

    Greetings,
    Radoslav Georgiev
    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. Paul
    Paul avatar
    24 posts
    Registered:
    16 May 2011
    06 Jun 2011
    Link to this post
    Lovely. I'll let you know how I get on :)
  4. Paul
    Paul avatar
    24 posts
    Registered:
    16 May 2011
    15 Jun 2011
    Link to this post
    Excellent. Thanks for that - it helped a treat!

    It seems a little cumbersome to hand-edit the client-side javascript file - it was this bit that took the time, and indeed is the hardest to debug. Is there an easy way to create a skeleton file with the relevant property stubs in it, or should I be taking one that already works and hacking about with it (the method I am currently employing)?

    Paul
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Jun 2011
    Link to this post
    Hi Paul,

    We use the ASP.NET ScriptControl implementation. For the client component you can create a template that will be almost the same for each of your custom widgets.

    Here are several articles that you can check.

    • http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-controls-working-with-control-designers.html
    • http://byatool.com/ui/creating-script-controls-and-love/



    Regards,
    Ivan Dimitrov
    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
  6. Abhilash Shamsunder
    Abhilash Shamsunder avatar
    10 posts
    Registered:
    05 Apr 2010
    22 Feb 2012
    Link to this post
    Excellent Post. Got it to work in less that 10 mins. :)

    Will have to tweak for my needs. Thanks!
6 posts, 0 answered