You are here: Ektron Namespace > .NET Assemblies > Ektron.Cms.API Namespace > Classes > Metadata Class > Metadata Methods > GetContentMetadataList Method > GetContentMetadataList
Ektron CMS400.NET API Documentation
ContentsIndexHome
PreviousUpNext
Metadata.GetContentMetadataList Method (Long)

Loads all of the metadata for the given content.

C#
public CustomAttributeList GetContentMetadataList(Long ContentId);
Visual Basic
Public Function GetContentMetadataList(ByVal ContentId As Long) As CustomAttributeList
Parameters 
Description 
ContentId 
The contents ID. 

Ektron.Cms.CustomAttributeList

The following example shows how to create a Web page from which all metadata for a specific content ID can be retrieved. This example uses some standard drag and drop controls and a small section of VB code utilizing the GetContentMetadataList(ByVal ContentId as Long) method. This method uses the InternalAdmin to retrieve the metadata for the content ID. In the first section, we will deal with the standard drag and drop controls. In the second, we'll deal with the code behind. 

 

  1. Between the form tags, add the following label.
       <asp:Label ID="Label1" runat="server" Text="Content ID: "></asp:Label>
  2. Add a text box to enter the content's ID.
       <asp:TextBox ID="txtContentId" runat="server" Width="63px"></asp:TextBox>
  3. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the Content ID box.
       <asp:RequiredFieldValidator ID="rfvContentId" runat="server" ControlToValidate="txtContentId"
                ErrorMessage="Please enter content ID"></asp:RequiredFieldValidator>
  4. Add two breaks for spacing purposes.
       <br /><br />
  5. Add a button to get the metadata. We will set the button click event in the code behind.
       <asp:Button ID="btnGetMetaData" runat="server" Text="Get MetaData" Width="91px" />
  6. Add two more breaks for spacing purposes.
       <br /><br />
  7. Add a label to display to display the metadata information.
       <asp:Label ID="lblResult" runat="server" Width="604px" Height="113px"></asp:Label>

 

Add the following information to the code behind of your aspx.vb page.

  1. Add a button click event.

       Protected Sub btnGetMetaData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMetaData.Click

  1. Create the following objects for the Metadata API, Custom Attribute List and each Custom Attribute item.

           Dim metaDataApi As New Ektron.Cms.API.Metadata
           Dim metaDataList As New Ektron.Cms.CustomAttributeList
           Dim metaItem As New Ektron.Cms.CustomAttribute

  1. Check to make sure the content ID is numeric.

           If Not IsNumeric(txtContentId.Text) Then
               lblResult.Text = "Invalid Content ID"
               Exit Sub
           End If

  1. Create a Try/Catch around the GetContentMetadataList method. This allows you to catch any exceptions and helps when debugging.

           Try                
               metaDataList = metaDataApi.GetContentMetadataList(CInt(txtContentId.Text))

  1. Verify that items are returned and create a table to display the returned information.

               If metaDataList.AttributeList.Length > 0 Then
                   lblResult.Text = "<table> <th>Metaname</th> <th align=""left"">Value</th> "

  1. Populate the table with metadata information and display it.

                   For Each metaItem In metaDataList.AttributeList
                       If metaItem.Value.ToString().Length > 0 Then
                           lblResult.Text &= "<tr>"
                           lblResult.Text &= "<td>" & metaItem.Name & "</td>"
                           lblResult.Text &= "<td>" & metaItem.Value & "</td>"
                           lblResult.Text &= "</tr>"
                       End If
                   Next
                   lblResult.Text &= "</table>"

  1. If no metadata exists, display that information.

               Else
                   lblResult.Text = "No metadata definitions found"
                   Exit Sub
               End If

  1. Display a message if there is an error.

           Catch ex As Exception
               lblResult.Text = ex.Message
           End Try
      End Sub
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at [email protected].
Copyright (c) 2008. All rights reserved.
What do you think about this topic? Send feedback!