Export (0) Print
Expand All

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 string ID { get; }

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 void Button1_Click(object sender, EventArgs e)
{
  Label1.Text = String.Empty;

  WebPartDescriptionCollection descriptions = 
    DeclarativeCatalogPart1.GetAvailableWebPartDescriptions();

  foreach (WebPartDescription desc in descriptions)
  {
    Label1.Text += "ID: " + desc.ID + "<br />" +
      "Title: " + desc.Title + "<br />" +
      "Description: " + desc.Description + "<br />" +
      "ImageUrl: " + desc.CatalogIconImageUrl + "<br />" +
      "<hr />";
  }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft