开发者

How can I tell if an SPField is a rich text box or a normal text box?

Can anyone tell me how I can find out if an SPField object is a rich text box or a normal text box? If it's a rich tex开发者_StackOverflowt box then I want to use the GetFieldValueAsHtml otherwise i want to use the GetFieldValueAsText methods. I have looked at SPField.Type but I am either blind (very possible) or it just has a Text option that represents all Text field.


Can you use the TypeAsString property? Others seem to have had issues finding the type.

string fieldType = spField.TypeAsString;


private bool IsRichTextField(SPListItem item, string fieldName)
{
    bool isRichText = false;

    if (item.Fields.ContainsField(fieldName) && item.Fields[fieldName] is SPFieldMultiLineText)
    {
        var multiLineField = item.Fields[fieldName] as SPFieldMultiLineText;
        isRichText = multiLineField.RichText;
    }

    return isRichText;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜