BulletedList.BulletImageUrl 屬性

定義

取得或設定要顯示成 BulletedList 控制項中各個項目符號之影像的路徑。

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

屬性值

要顯示成 BulletedList 中各個項目符號之影像的路徑。

範例

下列程式碼範例示範如何建立 BulletedList 控制項,並將 屬性設定 BulletImageUrl 為指定要用於每個專案符號之自訂影像的路徑。

<%@ Page Language="C#" %>

<!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>BulletImageUrl Example</title>
</head>
<body>

    <h3>BulletImageUrl Example</h3>

    <form id="form1" runat="server">
                    
        <asp:BulletedList id="ItemsBulletedList"             
        DisplayMode="Text" 
        BulletStyle="CustomImage"
        BulletImageUrl="Images/image1.jpg"
        runat="server">    
            <asp:ListItem Value="0">Coho Winery</asp:ListItem>
        <asp:ListItem Value="1">Contoso, Ltd.</asp:ListItem>
        <asp:ListItem Value="2">Tailspin Toys</asp:ListItem>
        </asp:BulletedList>                        
              
   </form>

</body>
</html>
<%@ Page Language="VB" %>

<!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>BulletImageUrl Example</title>
</head>
<body>

    <h3>BulletImageUrl Example</h3>

    <form id="form1" runat="server">
                    
        <asp:BulletedList id="ItemsBulletedList"             
        DisplayMode="Text" 
        BulletStyle="CustomImage"
        BulletImageUrl="Images/image1.jpg"
        runat="server">    
            <asp:ListItem Value="0">Coho Winery</asp:ListItem>
        <asp:ListItem Value="1">Contoso, Ltd.</asp:ListItem>
        <asp:ListItem Value="2">Tailspin Toys</asp:ListItem>
        </asp:BulletedList>                        
              
   </form>

</body>
</html>

備註

BulletImageUrl使用 屬性來指定要顯示為控制項中 BulletedList 每個專案符號之影像的路徑。 若要指定專案符號的自訂影像,您也必須將 BulletStyle 屬性設定為 值 CustomImage

注意

控制項 BulletedList 不支援 AlternateText 屬性,因為專案符號原本就具有裝飾性,而且不會提供需要透過輔助技術傳達的其他資訊。 不過,如果您想要使用自訂影像將概念傳達給使用者,您應該將額外的文字新增至每個項目符號清單專案,或使用可讓您為每個影像指定替代文字的控制項。

您可以指定影像的相對路徑或絕對路徑。 相對路徑會將影像的位置與網頁的位置建立關聯,而不指定伺服器上的完整路徑。 路徑相對於網頁的位置。 這可讓您更輕鬆地將整個月臺移至伺服器上的另一個目錄,而不需要更新程式碼。

下列程式碼範例顯示影像檔案的相對路徑:

\\Images\\image1.jpg
"Images\image1.jpg"

下列程式碼範例顯示影像檔案的絕對路徑:

"c:\\MyImagesDir\\image1.jpg"
"c"\MyImagesDir\image1.jpg"

這個屬性的值會儲存在檢視狀態中。

適用於

另請參閱