SPContentType.ValidateName method
確認是否是可接受做為內容的型別名稱的字串。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Shared Sub ValidateName ( _
name As String _
)
'用途
Dim name As StringSPContentType.ValidateName(name)
public static void ValidateName(
string name
)
參數
name
Type: System.String要驗證名稱。
備註
您可以使用這個方法來驗證名稱字串指派為內容類型的Name屬性的值之前。請注意這個方法不會驗證建議的名稱是否重複。當您嘗試使用Add方法,將內容類型加入至集合時,會進行檢查。
Examples
下列範例會從主控台應用程式。此範例會嘗試驗證刻意不正確的名稱。如此一來,擲回例外狀況時,與應用程式是列印到主控台的例外狀況訊息。
' 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.
請參閱
參照
Microsoft.SharePoint namespace