Partilhar via


Lists.UpdateContentType Method

Updates the specified list content type.

Namespace:  [Lists Web service]
Web service reference: http://Site/_vti_bin/Lists.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/UpdateContentType", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function UpdateContentType ( _
    listName As String, _
    contentTypeId As String, _
    contentTypeProperties As XmlNode, _
    newFields As XmlNode, _
    updateFields As XmlNode, _
    deleteFields As XmlNode, _
    addToView As String _
) As XmlNode
'Usage
Dim instance As Lists
Dim listName As String
Dim contentTypeId As String
Dim contentTypeProperties As XmlNode
Dim newFields As XmlNode
Dim updateFields As XmlNode
Dim deleteFields As XmlNode
Dim addToView As String
Dim returnValue As XmlNode

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

Parameters

  • listName
    Type: System.String

    A string that represents the name of the list on which the list content type resides.

  • contentTypeId
    Type: System.String

    A string that represents the content type ID of the list content type to be updated.

  • contentTypeProperties
    Type: System.Xml.XmlNode

    A string that represents the properties to update on the list content type.

    Format the properties as a ContentType element, and include the element attributes for the properties you want to update.

  • newFields
    Type: System.Xml.XmlNode

    A string that represents the collection of columns to add to the list content type.

    Format the column collection as a FieldRefs element, where each FieldRef child element references a column to add to the list content type.

  • updateFields
    Type: System.Xml.XmlNode

    A string that represents the collection of columns to update on the list content type.

    Format the column collection as a FieldRefs element, where each FieldRef references a column to update on the content type.

    In each FieldRef child element, include the element attributes for the column properties you want to update.

  • deleteFields
    Type: System.Xml.XmlNode

    A string that represents the collection of columns to delete from the list content type.

    Format the column collection as a FieldRefs element, where each FieldRef references a column to delete from the content type.

    In each FieldRef child element, include the ID attributes for the column you want to delete.

  • addToView
    Type: System.String

    A string that represents whether or not to add the content type columns to the list view. Specify true to add the columns to the list view, false to keep the columns hidden.

Return Value

Type: System.Xml.XmlNode

Examples

The following example updates the description of the specified list content type, and then displays the method results in a dialog box.

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

  Dim listName As String = "listName"
  Dim contentTypeId As String = "0x010100C78DE4D7C0C57C43AF878D28256599CA002E1A80DF76000C4780E09DDFFB90076D"
  Dim ctDescription As String = "Enter new list content type description here"
  Dim xmlDoc As New XmlDocument
  Dim xmlFields As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Fields", "")
  Dim xmlProps As XmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "ContentType", "")

  Dim xmlPropsDesc As XmlAttribute = xmlDoc.CreateAttribute("Description")
  xmlPropsDesc.Value = ctDescription
  xmlProps.Attributes.Append(xmlPropsDesc)

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

  Try
    'Update the list content type.
    xmlResult.InnerXml = listService.UpdateContentType(listName, contentTypeId, xmlProps, xmlFields, xmlFields, xmlFields, "true").OuterXml.ToString

    'Display the results.
      MessageBox.Show(xmlResult.InnerXml.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

See Also

Reference

Lists Class

Lists Members

Lists Web Service

Other Resources

Content Types

Content Type IDs