문제

I have a web system that has a few hooks into our TFS work item system. One of the things I am trying to do is that when a certain action is performed, it takes the current text in one field and makes a comment in the "General Comments" field announcing what the field was previously (Yes I know, history contains this but the higher ups want this in the gen comments).

The problem I am having is that TFS seems to be ignoring Environment.NewLines that I have in my string. So with this code:

                    item.Fields[GENCOMMENTS].Value = string.Concat(DateTime.Now.ToShortDateString()
                                , " - QA Dashboard - Required By Date Reason set to \"Hotfix\", but previously contained \""
                                , item.Fields[REQBYDTREASON].Value.ToString()
                                , "\"."
                                , Environment.NewLine
                                , Environment.NewLine
                                , Environment.NewLine
                                , item.Fields[GENCOMMENTS].Value.ToString());

So assuming my general comments section contains:

THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

I get the following output in the general comments section when the work item is saved

9/29/2010 - QA Dashboard - Required By Date Reason set to "Hotfix", but previously contained "hotfixtest".THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

Why is it ignoring the new lines and how can I get a new line into the work item?

Thanks,

도움이 되었습니까?

해결책

TFS work item content is often processed as HTML. That's likely happening here and hence it's ignoring the extraneous newlines in the text. Try wrapping the content in a <pre> block or using <p> and see if that fixes the issue.

다른 팁

RTF or HTMl controls will use and render html markup - so depends on the control. Try adding and formatting rich text to a multiline control and then debug it in a console app - browse the field value - you'll see html tags.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top