共用方式為


Lists.DeleteContentType method

從指定的清單中移除指定的清單內容類型。

Namespace:  WebSvcLists
Assembly:  STSSOAP (in STSSOAP.dll)

Syntax

'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/DeleteContentType", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function DeleteContentType ( _
    listName As String, _
    contentTypeId As String _
) As XmlNode
'用途
Dim instance As Lists
Dim listName As String
Dim contentTypeId As String
Dim returnValue As XmlNode

returnValue = instance.DeleteContentType(listName, _
    contentTypeId)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/DeleteContentType", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode DeleteContentType(
    string listName,
    string contentTypeId
)

參數

  • listName
    Type: System.String

    字串,包含要刪除的內容類型清單的名稱。

  • contentTypeId
    Type: System.String

    包含要刪除清單內容類型的內容類型識別碼的字串。

傳回值

Type: System.Xml.XmlNode
一個字串,以下列格式,指出在方法成功。

<Success xmlns="https://schemas.microsoft.com/sharepoint/soap/"/>

備註

You cannot delete a list content type if that content type is currently assigned to items in the list. For more information, see Content Type Deletion.

Examples

下列範例會刪除指定的清單內容類型。

Imports System.Xml
Imports System.Web.Services.Protocols
…
Public Sub DeleteListContentType()
  Dim listService As New Web_Reference_Folder.Lists
  listService.Credentials = System.Net.CredentialCache.DefaultCredentials

  'Specify the list and list content type ID.
  Dim listName As String = "listName"
  Dim strContentTypeId As String = "0x010100C78DE4D7C0C57C43AF878D28256599CA002E1A80DF76000C4780E09DDFFB90076D"

  'Create XML node for results.
  Dim xmlDoc As New XmlDocument
  Dim xmlResult As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Result", "")

  Try
  'Delete the content type.
  xmlResult.InnerXml = listService.DeleteContentType(listName, strContentTypeId).OuterXml.ToString

  'Display the results.
  MessageBox.Show(xmlResult.OuterXml.ToString)

  Catch ex As SoapException
    MessageBox.Show("Message:" + ControlChars.Lf + ex.Message & _
      ControlChars.Lf & _
    "Detail:" + ControlChars.Lf + ex.Detail.InnerText & _
      ControlChars.Lf & _
    "StackTrace:" & ControlChars.Lf + ex.StackTrace)

  Catch ex As Exception
    MessageBox.Show(ex.Message.ToString)

  End Try
End Sub

請參閱

參照

Lists class

Lists members

WebSvcLists namespace

其他資源

Content Types

Content Type IDs