Rich text in dataset - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Rich text in dataset

Last post 11-17-2010 03:29 PM by Rangi. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-31-2008 09:25 AM

    • run000
    • Not Ranked
    • Joined on 04-02-2008
    • Posts 8

    Rich text in dataset

    Hi everyone,

    I'm trying to show xhtml text in a expression box (mostly I need show links), this text is provided from a web service in a dataset. The problem is that the data is displayed as plain text. I was trying with many ways, and using this post like reference but I gave up. Can you help me?

    Thanks for your job.

    PD. I'm using Infopath 2003 (jscript code) and VS 2005 (c#)

  • 09-04-2008 06:57 AM In reply to

    • run000
    • Not Ranked
    • Joined on 04-02-2008
    • Posts 8

    Re: Rich text in dataset

    Hi again,

    Some weeks ago I found out the solution to this issue, I hope it can be helpful to someone. I coded the solution creating a new XHTML field in the main data source, and throwing an OnAfterChange event In thee original field (secondary data source). In this function I used this code:

    var answDiv = "<div xmlns=\"\">" + xmlString+ " "</div>";
    var ansXMLDoc = XDocument.CreateDOM();

  • 11-17-2010 03:29 PM In reply to

    • Rangi
    • Not Ranked
    • Joined on 11-16-2010
    • Posts 3

    Re: Rich text in dataset

    I could not get this working so I had to take a different tactic. The code below is written in C#, for IP2003. It uses the clipboard ala IPC.

    Call the method like so:

    insertRichText(@"<h1>foo</h1>", "//aRichTextField");

    And here is the method:

    public void insertRichText(string richText, string xPathForInsertion)



                StringBuilder sb;

                IXMLDOMNode xNodeTarget;

                Encoding encoding;

                string htmlPrefix;

                string htmlSuffix;



                xNodeTarget = thisXDocument.DOM.documentElement.selectSingleNode(xPathForInsertion);

                sb = new StringBuilder();

                encoding = Encoding.UTF8;

                htmlPrefix = @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""><html><head><meta http-equiv=Content-Type content=""text/html; charset={0}""></head><body><!--StartFragment-->";

                htmlSuffix = @"<!--EndFragment--></body></html>";

                htmlPrefix = string.Format(htmlPrefix, encoding.WebName);

                htmlSuffix = string.Format(htmlSuffix, encoding.WebName);


                //Add the top to the clip



                //Add the content to the clip



                //Add the bottom to the clip



                //Add the clip to the clipboard

                System.Windows.Forms.DataObject clipDO = new System.Windows.Forms.DataObject();

                clipDO.SetData(System.Windows.Forms.DataFormats.Html, sb.ToString());

                System.Windows.Forms.Clipboard.SetDataObject(clipDO, true);


                //Select field element

                thisXDocument.View.SelectText(xNodeTarget, Type.Missing);


                //Paste into element

                thisXDocument.View.ExecuteAction("Paste", Type.Missing);



Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.