ID Property
Collapse the table of content
Expand the table of content

WebPartDescription.ID Property

 

Gets the ID of a corresponding WebPart control.

Namespace:   System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

Public ReadOnly Property ID As String

Property Value

Type: System.String

A string that contains the ID of the control.

The value of the ID property cannot be null; it must always have a value. The ID property corresponds directly to the Control.ID property.

The ID property applies only when a page is in catalog display mode, and a WebPart control is being displayed in a catalog of controls.

The following code example demonstrates programmatic use of the ID property. For the full code required to run this code example, see the Example section of the WebPartDescription class overview topic.

The following code in the Button1_Click method of a Web page demonstrates how to get the collection of WebPartDescription objects in a catalog using the GetAvailableWebPartDescriptions method, and then to display the details of each WebPart control in the catalog by looping through the WebPartDescription objects. Note that the ID property value is retrieved in the following code.

Protected Sub Button1_Click(ByVal sender As Object, _
  ByVal e As System.EventArgs)

  Label1.Text = String.Empty

  Dim descriptions As WebPartDescriptionCollection = _
   DeclarativeCatalogPart1.GetAvailableWebPartDescriptions()

  Dim desc As WebPartDescription

  For Each desc In descriptions
    Label1.Text += "ID: " & desc.ID & "<br />" & _
      "Title: " & desc.Title & "<br />" & _
      "Description: " & desc.Description & "<br />" & _
      "ImageUrl: " & desc.CatalogIconImageUrl & "<br />" & _
      "<hr />"
  Next

End Sub

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft