This documentation is archived and is not being maintained.

Lists.DeleteContentType Method

Windows SharePoint Services 3
Removes the specified list content type from the designated list.

Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx

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

Parameters

listName

A string that contains the name of the list from which to delete the content type.

contentTypeId

A string containing the content type ID of the list content type to delete.

Return Value

A string, in the following format, indicating that the method succeeded.
<Success xmlns="http://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.

The following example deletes the specified list content type.

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
Show: