Widget with HtmlField - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Widget with HtmlField

  • Widget with HtmlField
  • Hi,

    I try to create widget with designer on Sitefinity 6.1. My widget contains two label controls. The widget designer contains one TextBox and one HtmlField. The TextBox in designer works fine. But I can't get value from widget and give it to the HtmlFiled indesigner. Also I can't get value from HtmlField and give it to the widget.
     I don't know what is wrong. ZIP with all files is here: www.develox.net/sitefinity/HtmlPanel.zip    
    Can anyone help me resolve this problem please?

    Thanks very much.

    Milan
  • Here you go mate.  First line is current code, 2nd line is replacement code.  These complex control need to be passed with AddComponentProperty

    Designer.cs:
    ------------
    descriptor.AddElementProperty("htmlText", this.HtmlText.ClientID);
    descriptor.AddComponentProperty("htmlText", this.HtmlText.ClientID);

    Designer.js:
    ------------
    jQuery(this.get_htmlText()).val(controlData.HtmlText);
    this.get_htmlText().set_value(controlData.HtmlText);

    controlData.HtmlText = jQuery(this.get_htmlText()).val();
    controlData.HtmlText = this.get_htmlText().get_value();



    Remember to parse your HTML string before display, as it will now potentially have [sfref] images, links etc..:

    HtmlPanel.cs:
    -------------
    htmlTextLabel.Text = this.HtmlText;
    htmlTextLabel.Text = LinkParser.ResolveLinks(LinkParser.UnresolveLinks(this.HtmlText), DynamicLinksParser.GetContentUrl, null, false)
  • Hi Stephen,

    thank you very much for your response. Your solution works fine. Could you please explain me where was the problem?
    I understand that I have to use the AddComponentProperty() for HTMLField. What about jQuery syntax? I see you are using direct access to the objects instead jQuery. Why?

    Another way: I used this together with AddElementProperty():
    -----------------------------------------------------------------
    this.get_htmlText().control.set_value(controlData.HtmlText);
    controlData.HtmlText = this.get_htmlText().control.get_value();

    And it works fine too.

    Thanks, Milan.

  • Glad I could help!  As to why ComponentProperty, or which way is better - I have no idea to be honest, I'm afraid I'm not experienced with any performance differences between the two methods.

    I always just "figure out what works" so if the ElementProperty way works too then I couldn't tell you which is better!  Good job figuring it out though.
  • Stephen, thank you for help!
    For everyone, here is example, which works properly: www.develox.net/sitefinity/HtmlPanel.zip

    Good luck!
  • Hi Milan,

    I'm having the same issue.  The link to your solution file is no longer working.  Would it be possible for you to attach your solution to your response?

    Thank you.
  • Hi John,

    the link is corrected. I am sorry. Try it again.
    Thank you for your notice.