且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在ASPX从code图像背后(ASP.NET C#)图像列表概述

更新时间:2023-02-24 23:12:32

您可以使用GridView来显示图像,不知道到底你在code背后有那么我创建了一个简单的列表与LT什么类型的列表;图片> ,其中图片是具有两个属性名称和URL一类,但我相信你可以改变code据此与您的清单工作:

Question 1

You can use a gridview to display the images, not sure exactly what type of list you have in your code behind so I've created a simple List<Images> where Images is a class with two properties Name and URL, but I trust you can change the code accordingly to work with your list:

ASPX:

<asp:GridView ID="gvImages" runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:ImageField DataImageUrlField="URL" HeaderText="Image" 
        ControlStyle-Height="150" ControlStyle-Width="120" />
    </Columns>
</asp:GridView>

后面的 code:

    protected void Page_Load(object sender, EventArgs e)
    {
        List<Image> images = new List<Image>
        {
            new Image("Picture 1","~/Images/Pic1.jpg"),
            new Image("Picture 2","~/Images/Pic2.jpg"),
        };

        gvImages.DataSource = images;
        gvImages.DataBind();
    }
}

public class Image
{
    public Image(string name, string url)
    {
        this.name = name;
        this.url = url;
    }

    private string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    private string url;
    public string URL
    {
        get { return url; }
        set { url = value; }
    }
}

问题2

看一看 jQuery的广场的它的功能,列出所有的缩略图,以及下一个和previous buttons.And如果你想显示的名称或图像的任何其他类别的上空盘旋图像时只需更改标题 HTML属性所需的值:

Question 2

Have a look at jQuery Galleria it has functionality to list all the thumbnails as well as the next and previous buttons.And if you want to display the name or any other description of the image when hovering over the image just change the title HTML attribute to the desired value:

在ASPX从code图像背后(ASP.NET C#)图像列表概述