What text type are multi line text columns in SharePoint lists?
-
10-12-2019 - |
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.
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()
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