WebPart.TitleIconImageUrl 属性

定义

获取或设置图像的 URL,该图像用于在控件的标题栏中表示 Web 部件控件。

public:
 virtual property System::String ^ TitleIconImageUrl { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.WebControls.WebParts.Personalizable(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)]
public virtual string TitleIconImageUrl { get; set; }
[<System.Web.UI.WebControls.WebParts.Personalizable(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)>]
member this.TitleIconImageUrl : string with get, set
Public Overridable Property TitleIconImageUrl As String

属性值

String

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

实现

属性

例外

内部验证系统已确定 URL 可能包含脚本攻击。

示例

下面的代码示例演示如何设置TitleIconImageUrl自定义Web 部件控件的属性,以便控件在控件目录中显示图像。 此示例假定使用在类概述的“示例”部分中WebPart创建的自定义控件TextDisplayWebPart

在网页的声明性标记中,记下 <aspSample:TextDisplayWebPart> 该元素。 其 TitleIconImageUrl 属性分配了一个字符串,其中包含图像文件的 URL。 在浏览器中加载页面,如果为图像提供了合法的 URL,图像将显示在控件的 WebPart 标题栏中。

<%@ page language="C#" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.CS.Controls" 
             Assembly="TextDisplayWebPartCS"%>

<!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 id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc" />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            TitleIconImageUrl="MyImage.gif" />
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>
<%@ page language="VB" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.VB.Controls" 
             Assembly="TextDisplayWebPartVB"%>

<!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 id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc" />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            TitleIconImageUrl="MyImage.gif" />
        </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>

注解

此属性的个性化范围设置为 Shared 授权用户,并且只能由授权用户修改。 有关详细信息,请参阅PersonalizableAttributeWeb 部件个性化设置概述

适用于

另请参阅