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

屬性值

字串,表示至影像的 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 元件個人化概觀

適用於

另請參閱