Question

When accessing a multi line text field from a SharePoint item in a list, what is the text type returned?

Using C#:

item["Description"].ToString()

Is the above plaintext or html or...?

I want to format the text to be put in a HTML email ultimately, but all formatting of the string in the actual description is lost when doing so.

Was it helpful?

Solution

You may have to change the description column using Powershell to include HTML.

$Web = Get-SPWeb "yoururl.domain.com/particularweb"
$Field = $web.Fields | ?{$_.staticname -eq "MyCustomColumn"}
$Field.RichText = $True
$Field.RichTextMode = "FullHtml"
$Field.Update()

Source: http://social.technet.microsoft.com/Forums/nl-NL/sharepointadminprevious/thread/a6d1b087-4d06-4e8f-8f69-043e15b04819

EDIT: Try this:

SPFieldMultiLineText multilineField = item.Fields.GetField(COLUMN_NAME) as SPFieldMultiLineText;

 if (multilineField != null)
 {
 // Get the field value as HTML
 string text = multilineField.GetFieldValueAsHtml(item[COLUMN_NAME], item);
 }

Source: http://blog.myitechnology.com/2009/06/append-new-line-to-spfieldmultilinetext.html

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top