TitleIconImageUrl Property

GenericWebPart.TitleIconImageUrl Property


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

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

public override string TitleIconImageUrl { get; set; }

Property Value

Type: System.String

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 GenericWebPart control. The icon appears in the control's own title bar. For thematic consistency, application developers often 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.

This property overrides the base property so that you can access the property on the child control as if it were a true WebPart control.

You can set values for the property on your control in the declarative markup of a Web page, as well as programmatically. To provide a default value for the property whenever the control is used, you can implement the IWebPart interface.

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 GenericWebPart overview topic.

The first part of the code example shows how the TitleIconImageUrl property is set declaratively on a server control within a WebPartZone control.

<asp:WebPartZone ID="WebPartZone1" runat="server">
    <asp:Calendar ID="Calendar1" runat="server"
      Title="My Calendar"
      Description="A calendar used as a GenericWebPart control."
      TitleIconimageUrl ="MyTitleIcon.gif"

The second part of the code example demonstrates how to access the property programmatically to display its value in a label.

protected void Button1_Click(object sender, EventArgs e)

  Label2.Text =
    @"<h3>Calendar GenericWebPart Properties</h3>" +
    "<em>Title: </em>" + calendarPart.Title +
    "<br />" +
    "<em>CatalogIconImageUrl:  </em>" + calendarPart.CatalogIconImageUrl +
    "<br />" +
    "<em>TitleUrl: </em>" + calendarPart.TitleUrl +
    "<br />" +
    "<em>Decription: </em>" + calendarPart.Description +
    "<br />" +
    "<em>TitleIconImageUrl: </em>" + calendarPart.TitleIconImageUrl +
    "<br />" +
    "<em>ChildControl ID: </em>" + calendarPart.ChildControl.ID +
    "<br />" +
    "<em>ChildControl Type: </em>" + calendarPart.ChildControl.GetType().Name +
    "<br />" +
    "<em>GenericWebPart ID: </em>" + calendarPart.ID +
    "<br />" +
    "<em>GenericWebPart Type: </em>" + calendarPart.GetType().Name +
    "<br />" +
    "<em>GenericWebPart Parent ID: </em>" + calendarPart.Parent.ID;

  Label3.Text =
    @"<h3>BulletedList GenericWebPart Properties</h3>" +
    "<em>Title: </em>" + listPart.Title +
    "<br />" +
    "<em>CatalogIconImageUrl:  </em>" + listPart.CatalogIconImageUrl +
    "<br />" +
    "<em>TitleUrl: </em>" + listPart.TitleUrl +
    "<br />" +
    "<em>Decription: </em>" + listPart.Description +
    "<br />" +
    "<em>TitleIconImageUrl: </em>" + listPart.TitleIconImageUrl +
    "<br />" +
    "<em>ChildControl ID: </em>" + listPart.ChildControl.ID +
    "<br />" +
    "<em>ChildControl Type: </em>" + listPart.ChildControl.GetType().Name +
    "<br />" +
    "<em>GenericWebPart ID: </em>" + listPart.ID +
    "<br />" +
    "<em>GenericWebPart Type: </em>" + listPart.GetType().Name +
    "<br />" +
    "<em>GenericWebPart Parent ID: </em>" + listPart.Parent.ID;

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft