IWebPart.Subtitle Propiedad

Definición

Obtiene una cadena que se concatena con el valor de la propiedad Title para formar un título completo para un control WebPart.

public:
 property System::String ^ Subtitle { System::String ^ get(); };
public string Subtitle { get; }
member this.Subtitle : string
Public ReadOnly Property Subtitle As String

Valor de propiedad

String

Una cadena que sirve de subtítulo del control. El valor predeterminado es una cadena vacía ("").

Ejemplos

En el ejemplo de código siguiente se muestra el uso declarativo y mediante programación de la Subtitle propiedad . El código fuente completo del ejemplo se encuentra en la sección Ejemplo de la información general de la IWebPart clase.

La primera parte del ejemplo de código muestra cómo el control de usuario implementa la Subtitle propiedad . Tenga en cuenta que la propiedad es de solo lectura y está pensada para usarse para proporcionar un subtítulo predeterminado que se anexa al título principal de un control.

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

    return (string)objSubTitle;
  }

}
ReadOnly Property Subtitle() As String _
  Implements IWebPart.Subtitle
  Get
    Dim objSubTitle As Object = ViewState("Subtitle")
    If objSubTitle Is Nothing Then
      Return "My Subtitle"
    End If
    Return CStr(objSubTitle)
  End Get
End Property

La segunda parte del ejemplo de código muestra cómo se hace referencia al control de usuario que implementa la IWebPart interfaz en un WebPartZone control y cómo las propiedades grabables de IWebPart se establecen declarativamente en el control. Después de cargar la página en un explorador, tenga en cuenta que el valor predeterminado de la Subtitle propiedad , que se estableció en el código de implementación del control de usuario, se anexa al título de la barra de título del control.

<%@ page language="c#" %>
<%@ register tagprefix="uc1" 
    tagname="AccountUserControlCS" 
    src="AccountUserControlcs.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      Personalizable User Control with IWebPart Properties
    </title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server" />
      <asp:webpartzone 
        id="zone1" 
        runat="server" 
        headertext="Main" 
        CloseVerb-Enabled="false">
        <zonetemplate>
          <uc1:AccountUserControlCS 
            runat="server" 
            id="accountwebpart" 
            title="Account Form"
            Description="Account Form with default values."
            CatalogIconImageUrl="MyCatalogIcon.gif"
            TitleIconImageUrl="MyTitleIcon.gif"
            TitleUrl="MyUrl.html"/>
        </zonetemplate>
      </asp:webpartzone>    
    </form>
  </body>
</html>
<%@ page language="VB" %>
<%@ register tagprefix="uc1" 
    tagname="AccountUserControlVB" 
    src="AccountUserControlvb.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>
      Personalizable User Control with IWebPart Properties
    </title>
  </head>
  <body>
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server" />
      <asp:webpartzone 
        id="zone1" 
        runat="server" 
        headertext="Main" 
        CloseVerb-Enabled="false">
        <zonetemplate>
          <uc1:AccountUserControlVB 
            runat="server" 
            id="accountwebpart" 
            title="Account Form"
            Description="Account Form with default values."
            CatalogIconImageUrl="MyCatalogIcon.gif"
            TitleIconImageUrl="MyTitleIcon.gif"
            TitleUrl="MyUrl.html"/>
        </zonetemplate>
      </asp:webpartzone>    
    </form>
  </body>
</html>

Comentarios

La Subtitle propiedad se usa para devolver una cadena de subtítulo predeterminada para un WebPart control que se anexa al título del control en la barra de título.

Si proporciona un valor predeterminado para la Subtitle propiedad en un control que implementa la IWebPart interfaz, el elementos web conjunto de controles lo anexa automáticamente al valor de la Title propiedad del control en tiempo de ejecución.

Se aplica a

Consulte también