How to insert markup text in RTF from script

R

Ruben Bos

I want to insert markup text into an RTF control using script. Basically I
have a button and when it is pressed a piece of text should apear in a RTF
control but with a bold title in a large font.

Inserting text itself is no problem but when I use things like <font>, <b>
tags they are displayed as text and not formatted.

Anybody a solution?
 
S

S.Y.M. Wong-A-Ton

You're probably setting the "text" property on the RTF field, which won't
work for what you're trying to achieve. You need to add the piece of text as
a child XML node to the RTF field. Here's an example in JScript:

xmlNode = XDocument.CreateDOM();
xmlNode.loadXML("<strong xmlns=\"http://www.w3.org/1999/xhtml\">bold
text</strong>")
XDocument.DOM.selectSingleNode("//my:RTF_field").appendChild(xmlNode.documentElement);
 
R

Ruben Bos

Mister, you're the man! You're the king. It works perfectly. Thanks! I read
like 12 hours for a solution, nothing seemed to work, and finally you came up
with an answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top