Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / April 2005

Tip: Looking for answers? Try searching our database.

How to set xhtml in InfoPath

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Li - 26 Sep 2004 22:02 GMT
I use rich text control, and I want to set data in the control by code, sore
line breaks <div></div>

strValue = "<div xmlns=""http://www.w3.org/1999/xhtml"">" + Value + "</div>"

Node xml is readonly, How can I set?

Thanks
Brian Teutsch [MSFT] - 27 Sep 2004 18:59 GMT
Because you say the XML is read-only, I think your first issue is that
you're trying to make the change in onBeforeChange. All XML is read-only
there; you should use onAfterChange if you want to set data after a user
modification.

Here's some sample code to help you out. You'll have to update the node
names and namespaces for your specific solution.

// Takes HTML from a plain text field and inserts it as XHTML into a Rich
Text field.
// HTML could come from another source. It must be valid XML, and this is
not verified.
var textfield = null;
var htmlfield = null;
textfield = XDocument.DOM.getElementsByTagName("myNode:node1")[0];
htmlfield = XDocument.DOM.getElementsByTagName("myNode:node2")[0];
if (textfield.text != "")
{
   var xdocFrag = new ActiveXObject("Msxml2.DOMDocument.5.0");
   var ns = "xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"
xmlns:myNode=\"http://schemas.microsoft.com/office/xdocs/2003/myXSD\""
xdocFrag.async = false;
   xdocFrag.validateOnParse = false;
   xdocFrag.loadXML("" + textfield.text + "");
   var newChild = xdocFrag.documentElement.firstChild;
   htmlfield.parentNode.replaceChild(xdocFrag.documentElement.firstChild,
htmlfield);
}

Thanks,
Brian

>I use rich text control, and I want to set data in the control by code,
>sore
[quoted text clipped - 6 lines]
>
> Thanks
Li - 27 Sep 2004 20:54 GMT
Thank you for your help

> Because you say the XML is read-only, I think your first issue is that
> you're trying to make the change in onBeforeChange. All XML is read-only
[quoted text clipped - 38 lines]
> >
> > Thanks
Nicole - 25 Apr 2005 14:53 GMT
hello Brian,

  Please I need your help.

  Can you please show me sample code on how to do it exactly using
  managed code. I'm already getting desperate as I have spent almost
  a week trying to figure out how to do it.

  Many thanks.

Kind regards
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.