SPContentType.ValidateName 方法
确认字符串是否是可接受作为内容类型的名称。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Shared Sub ValidateName ( _
name As String _
)
用法
Dim name As StringSPContentType.ValidateName(name)
public static void ValidateName(
string name
)
参数
name
类型:System.String要验证的名称。
备注
可以使用此方法来验证之前将其分配内容类型的Name属性的值作为名称字符串。请注意此方法不验证建议的名称是否是重复。当您尝试使用Add方法向集合添加内容类型进行检查。
示例
下面的示例来自控制台应用程序。该示例尝试验证有意无效的名称。因此,引发异常,并应用程序打印到控制台异常消息。
' Decide on a name for the new content type.
Dim contentTypeName As String = "R&D"
Try
SPContentType.ValidateName(contentTypeName)
Catch ex As SPException
Console.WriteLine(ex.Message)
End Try
// Decide on a name for the new content type.
string contentTypeName = "R&D";
try
{
SPContentType.ValidateName(contentTypeName);
}
catch (SPException ex)
{
Console.WriteLine(ex.Message);
}
代码示例打印以下输出到控制台。
The content type name cannot contain: \ / : * ? " # % < > { } | ~ &, two consecutive periods (..), or special characters such as a tab.