GenericWebPart.CatalogIconImageUrl 属性

定义

获取或设置图像的 URL,该图像在控件目录中表示一个 GenericWebPart 控件。

public:
 virtual property System::String ^ CatalogIconImageUrl { System::String ^ get(); void set(System::String ^ value); };
public override string CatalogIconImageUrl { get; set; }
member this.CatalogIconImageUrl : string with get, set
Public Overrides Property CatalogIconImageUrl As String

属性值

表示图像的 URL 的字符串,该图像用于在目录中表示控件。 默认值为空字符串 ("")。

示例

下面的代码示例演示了 属性的 CatalogIconImageUrl 声明性和编程用法。 有关示例的完整源代码,请参阅概述主题的“示例” GenericWebPart 部分。

代码示例的第一部分演示了如何在 CatalogIconImageUrl 控件内的 WebPartZone 服务器控件上以声明方式设置 属性。

<asp:WebPartZone ID="WebPartZone1" runat="server">
  <ZoneTemplate>
    <asp:Calendar ID="Calendar1" runat="server"
      Title="My Calendar"
      Description="A calendar used as a GenericWebPart control."
      CatalogIconImageUrl="MyCatalogIcon.gif"
      TitleIconimageUrl ="MyTitleIcon.gif"
      TitleUrl="MyInfoUrl.htm" 
      Width="250"/>
  </ZoneTemplate>
</asp:WebPartZone>
<asp:WebPartZone ID="WebPartZone1" runat="server">
  <ZoneTemplate>
    <asp:Calendar ID="Calendar1" runat="server"
      Title="My Calendar"
      Description="A calendar used as a GenericWebPart control."
      CatalogIconImageUrl="MyCatalogIcon.gif"
      TitleIconimageUrl ="MyTitleIcon.gif"
      TitleUrl="MyInfoUrl.htm" 
      Width="250"/>
  </ZoneTemplate>
</asp:WebPartZone>

代码示例的第二部分演示了当用户单击“ 显示所有 属性值”按钮时以编程方式访问属性值的方法。

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;
}
  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

    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
  End Sub

End Class

注解

Web 部件应用程序通常提供目录 (或列表) 控件,用户可以添加到页面。 CatalogIconImageUrl控件上的 属性包含图像的 URL,该图像在控件出现在目录中时表示该控件。 此属性重写基属性,以便你可以像访问真实 WebPart 控件一样访问子控件上的 属性。

可以在网页的声明性标记中以及以编程方式设置控件上的 属性的值。 若要在使用 控件时为 属性提供默认值,可以实现 IWebPart 接口。

适用于

另请参阅