Thursday, April 26, 2012 9:59 AM
When using a "HTML" field type in a work item defintion, is it possible .. or how is it possible to write raw html to it? Basically when writing to workitem.Fields["MyHtmlField"].Value the html string, it apparently gets escaped, so next time I load it I get e.g. <p>sometext</p> .. etc instead of sometext in a paragraph.
How would i do that?
Best regards and thanks,
Monday, April 30, 2012 8:04 AMModerator
As far as I know that the HTML field in the TFS work item does not only contain the string value but also contain the formate styles. So if you would like to write data to the HTML field via TFS API, you need to first convert these formated characters to escaped characters and then add the escaped characters to the HTML field.
Vicky Song [MSFT]
MSDN Community Support | Feedback to us
Friday, May 04, 2012 5:04 PM
To convert plain text to HTML try to use use following method and the simply assign the converted string to your HTML field.
String htmlText = System.Web.HttpUtility.HtmlEncode(plainText); m_workItem.Fields[HTMLFieldName].Value = htmlText;
I hope it helps
Friday, May 04, 2012 8:36 PM
Good evening ezien,
thanks for your proposed answer, but I was not refering to a 'normal' html field, but the Test Steps one in Test Cases which are not HTML per se, just stored in a field of that type. The data format is in fact different and I have problems writing that particular data to the field.