RadMarkupEditor TextChanged event

3 posts, 0 answers
  1. T
    T avatar
    8 posts
    Member since:
    Jan 2015

    Posted 26 Jun 2015 Link to this post


    I have a RadMarkupEditor on my form and I want to execute some action when the text in the editor is changed. Since this control inherits from System.Windows.Forms.UserControl we can subscribe to the TextChanged event. Unfortunately this event is never fired. Is this normal behavior? Is there any other event I could use to achieve the same?



  2. Stefan
    Stefan avatar
    2908 posts

    Posted 29 Jun 2015 Link to this post

    Hello Tom,

    Thank you for writing.

    Currently, RadMarkupEditor does not provide such notifications, however, with some reflection, we can achieve it. Here is a small sample:
    protected override void OnLoad(EventArgs e)
        RadMarkupDialog dialog = new RadMarkupDialog();
        WebBrowser designView = dialog.Editor.GetType().GetField("designView", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(dialog.Editor) as WebBrowser;
        designView.DocumentCompleted += delegate
            lastSavedText = designView.Document.Body.InnerHtml;
            designView.Document.Body.KeyUp += Body_KeyUp;
        TextBox htmlView = dialog.Editor.GetType().GetField("htmlView", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(dialog.Editor) as TextBox;
    void htmlView_TextChanged(object sender, EventArgs e)
        //occurs when the text in the Html tab changes
    string lastSavedText = "";
    void Body_KeyUp(object sender, HtmlElementEventArgs e)
        HtmlElement element = (HtmlElement)sender;
        if (this.lastSavedText != element.Document.Body.InnerHtml)
            //design view is modified
            lastSavedText = element.Document.Body.InnerHtml;

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.


  3. T
    T avatar
    8 posts
    Member since:
    Jan 2015

    Posted 30 Jun 2015 in reply to Stefan Link to this post

    Yes, this worked for me.


Back to Top