Saturday, May 30, 2009

Validating Content type name

Scenario:
Validating content type name while creating programaticaly

Solution:
Code:

// Decide on a name for the new content type.
string contentTypeName = "R&D";
try
{
SPContentType.ValidateName(contentTypeName);

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

0 comments: