Tags

, ,

If you acces the value of a multiline field there will be HTML tags included, so… the way to get only the text is like this…

SPFieldMultiLineText field = (SPFieldMultiLineText)item.Fields[“FieldName”];
string text = field.GetFieldValueAsText(item[“FieldName”]);

I wrote an exstension method for this:

var text = item.RetrieveMultiLineValue(“fieldname”);

Method:

public static string RetrieveMultiLineValue(this SPListItem item, string fieldname)
{
string text = String.Empty;

if (item[fieldname] != null)
{
SPFieldMultiLineText field = (SPFieldMultiLineText)item.Fields[fieldname];
text = field.GetFieldValueAsText(item[fieldname]);
}

return text;
}

Voila, hope it helps, comments are welcome…