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

Forums / Developing with Sitefinity / User control with Multiline textbox instead of single

User control with Multiline textbox instead of single

6 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    17 Aug 2010
    Link to this post
    Hi,

    Im developing a very simple user control that allows the user to input a title <plain text>, select an image from the library, and then enter a paragraph of text. The paragraph of text will not contain any HTML, however it may be 4 or 5 lines long. Using a standard <string> property means that sitefinity displays a standard, single line text box, whereas i really want a multiline one.

    Is there anything available out of the box to acheive this or do i need to develop a simple Type Editor?

    private string _strIntroText;
     
    [Category("Content")]
    [Description("Introduction text")]
    [DisplayName("Introduction text")]
    public string strIntoText {
     
        get {
     
            if (String.IsNullOrEmpty(_strIntroText)) {
                return "Page title";
            }
            return _strIntroText;
     
        }
     
        set {
     
            _strIntroText = value;
     
        }
     
    }

    Thanks in advance
    higgsy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Aug 2010
    Link to this post
    Hello Alastair,

    You can use ControlDesigner or WebUITypeEditor

    Best wishes,
    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
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    17 Aug 2010
    Link to this post
    Hi Ivan,

    I ended up creating a very basic WebUITypeEditor with a RadEditor. Although I am experiencing just 1 error:

    My code:
    private RadEditor _oEditor;
     
    public override string Value {
        get {
            string obj = (string)this.ViewState["Text"];
            return (string)_oEditor.Content;
        }
        set {
            this.ViewState["Text"] = value;
            base.ChildControlsCreated = false;
        }
    }
     
    protected override void CreateChildControls() {
        base.CreateChildControls();
     
        _oEditor = new RadEditor();
        _oEditor.EnableEmbeddedSkins = true;
        _oEditor.ToolsFile = "~/lib/xml/BasicRadEditorConfig.xml";
        _oEditor.ContentAreaCssFile = "~/SiteFinity/ControlTemplates/EditorContentArea.css";
        _oEditor.BackColor = System.Drawing.Color.White;
        _oEditor.Skin = "Default";
        _oEditor.Width = 550;
        _oEditor.Height = 375;
        _oEditor.ContentFilters = EditorFilters.FixEnclosingP;     
     
        //load existing content
        if (this.ViewState["Text"] != null) {
     
            _oEditor.Content = (string)this.ViewState["Text"];
     
        }
     
        //add control
        Controls.Add(_oEditor);
         
    }

    The problem is that whenever the user controls loads there is a single "<br>" in the HTML code. This poses two issues for me:

    1) A <br> tag is not valid XHTML
    2) I want anything the user enters to be wrapped in a <p> tag.

    Can these issues be resolved?

    Thanks
    higgsy
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Aug 2010
    Link to this post
    Hello Alastair,

    Try adding ConvertToXhtml. You could also take a look at IE 8 issue

    You can wrap the whole content in <p> tag using get_html and set_html methods.

    Kind regards,
    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
  5. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    18 Aug 2010
    Link to this post
    Hi Ivan,

    Thanks for your response.

    Adding the ConvertToXHTML does render the <br> tag as <br /> which is better. However the post you have pointed me to does little to fix this issue:

    "Please try to remove the "FixEnclosingP" filter from the ContentFilters of the RadEditor.
    You will need to use external templates. Just open the template you need, find the RadEditor and edit the ContentFilters section."

    What external template? Im embedding the RadEditor in my own WebUITypeEditor, and have added the ContentFilter there, so presumably the external template is not needed?

    The RadEditor not correctly formatting HTML is a huge problem, its the main method that content editors have for inputting content, if its wrong the HTML throughout the site is wrong!

    The problem extemnds further because if i manually go into the HTML and enter <p>Hello there</p>, hit enter, i get:

    <p>Hello there</p><p></p> - which isnt correct....

    If I cant rely on the HTML editor I have no choice but to completely remove the RadEditor from SiteFinity, which almost isnt possible unless I want to re-engineer the whole thing.

    Do you have any suggestions?

    Regards,
    higgsy

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Aug 2010
    Link to this post
    Hi Alastair,

    I am not able to reproduce these problems using custom RadEditor selector using IE 8 and FF 3.6.8. Sample video has been attached.

    As for the mapping templates  - this is not necessary, the main point was to remove the filter.

    All the best,
    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
Register for webinar
6 posts, 0 answered