SPContentType.ValidateName Method

Confirms whether a string is acceptable as the name for a content type.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

public static void ValidateName(
	string name


Type: System.String

A name to validate.

You can use this method to validate a name string before assigning it as the value of a content type’s Name property. Note that this method does not verify whether the proposed name is a duplicate. That check is made when you try to add the content type to a collection by using the Add method.

The following example is taken from a console application. The example attempts to validate an intentionally invalid name. As a result, an exception is thrown, and the application prints the exception message to the console.

// Decide on a name for the new content type.
string contentTypeName = "R&D";

catch (SPException ex)

The example code prints the following output to the console.

The content type name cannot contain: \  / : * ? " # % < > { } | ~ &, two consecutive periods (..), or special characters such as a tab.