IWebPart.Subtitle Property


Gets a string that is concatenated with the Title property value to form a complete title for a WebPart control.

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

string Subtitle { get; }

Property Value

Type: System.String

A string that serves as a subtitle for the control. The default value is an empty string ("").

The Subtitle property is used to return a default subtitle string for a WebPart control that is appended to the control's title in the title bar.

If you provide a default value for the Subtitle property in a control that implements the IWebPart interface, the Web Parts control set automatically appends it to the value of the Title property of the control at run time.

The following code example demonstrates declarative and programmatic use of the Subtitle 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 Subtitle property. Note that the property is read-only and is meant to be used to provide a default subtitle that is appended to the main title of a control.

public string Subtitle
    object objSubTitle = ViewState["Subtitle"];
    if (objSubTitle == null)
      return "My Subtitle";

    return (string)objSubTitle;


The second part of the code example shows how the user control that implements the IWebPart interface is referenced in a WebPartZone control, and how the writable properties from IWebPart are set declaratively on the control. After you load the page in a browser, note that the default value of the Subtitle property, which was set in the user control's implementation code, is appended to the title in the control's title bar.

<%@ page language="c#" %>
<%@ register tagprefix="uc1" 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" >
  <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."

.NET Framework
Available since 2.0
Return to top