IWebPart.TitleIconImageUrl Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the URL to an image used to represent a Web Parts control in the control's own title bar.

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

string TitleIconImageUrl { get; set; }
/** @property */
String get_TitleIconImageUrl ()

/** @property */
void set_TitleIconImageUrl (String value)

function get TitleIconImageUrl () : String

function set TitleIconImageUrl (value : String)

Property Value

A string that represents the URL to an image. The default value is an empty string ("").

The TitleIconImageUrl property provides a way to associate an icon with a WebPart control. The icon appears in the control's own title bar. For thematic consistency, application developers might want to make this icon similar to the image that represents the control in a catalog of Web Parts controls (the image referenced in the CatalogIconImageUrl property).

As it is implemented in the Web Parts control set, the TitleIconImageUrl property can be personalized by end users to change the image or icon that appears in a control's title bar.

The following code example demonstrates declarative and programmatic use of the TitleIconImageUrl property. The complete source code for the example is found in the Example section of the IWebPart class overview.

The first part of the code example shows how the user control implements the TitleIconImageUrl property.

public string TitleIconImageUrl
    object objTitle = ViewState["TitleIconImageUrl"];
    if (objTitle == null)
      return String.Empty;

    return (string)objTitle;
    ViewState["TitleIconImageUrl"] = value;

The second part of the code example demonstrates the method in the user control that programmatically sets the value of the TitleIconImageUrl property when a user selects the appropriate property name from the radio buttons on the page, sets a new value in the text box, and then clicks the Update button.

// Update the selected IWebPart property value.
void Button1_Click(object sender, EventArgs e)
  String propertyValue = Server.HtmlEncode(TextBox3.Text);
  TextBox3.Text = String.Empty;

  switch (RadioButtonList1.SelectedValue)
    case "title":
      this.Title = propertyValue;
    case "description":
      this.Description = propertyValue;
    case "catalogiconimageurl":
      this.CatalogIconImageUrl = propertyValue;
    case "titleiconimageurl":
      this.TitleIconImageUrl = propertyValue;
    case "titleurl":
      this.TitleUrl = propertyValue;

The third part of the code example shows how the user control that implements the IWebPart interface is referenced in a WebPartZone control, and how the TitleIconImageUrl property is set declaratively on the control. Note that if you do not provide the URL to a real image, a placeholder for the icon appears in the title bar.

<%@ page language="c#" %>
<%@ register tagprefix="uc1" 
  <head runat="server">
      Personalizable User Control with IWebPart Properties
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server" />
            title="Account Form"
            Description="Account Form with default values."

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

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

.NET Framework

Supported in: 2.0

Community Additions