語言

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。

Note

控制系統 BulletedList 不支持該物業, AlternateText 因為子彈本質上具有裝飾性,無法提供需要透過輔助技術傳達的額外資訊。 不過,如果你想用自訂圖片向使用者傳達概念,應該在每個項目符號列表項目中加入額外文字,或使用控制項來指定每張圖片的替代文字。

你可以指定相的相對路徑或絕對路徑。 相對路徑是將圖片的位置與網頁位置關聯起來,但不指定伺服器上的完整路徑。 路徑是相對於網頁的位置。 這樣可以更容易將整個網站移到伺服器上的另一個目錄,而不必更新程式碼。

以下程式碼範例展示了影像檔案的相對路徑:

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

以下程式碼範例展示了影像檔案的絕對路徑:

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

此屬性的價值會儲存在視圖狀態。

適用於

另請參閱