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"

此属性的值存储在视图状态中。

适用于

另请参阅