在ASPX从code图像背后(ASP.NET C#)图像列表概述 [英] List with images from code behind (ASP.NET C#) to image overview in ASPX

查看:128
本文介绍了在ASPX从code图像背后(ASP.NET C#)图像列表概述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的ASP和C#,我想了解我怎么能解决以下两个问题:

I am rather new to ASP and C#, and I would like to learn how I can solve the following two problems:


  1. 在code后面我有图片(来自数据库)的列表。我想显示ASPX页面上的这些图像。我想知道什么是允许的ASPX页面从后面的code访问列表的最佳/最简单的方法。有关此主题的教程是有点混乱给我。

  1. In the Code Behind I have a list with images (from database). I would like to show these images on the ASPX page. I was wondering what is the best/easiest way to allow an ASPX page to access lists from the code behind. The tutorials about this subject are a bit confusing to me.

第二个问题我有是关于一个不错的JQuery的画廊。 pretty多所有的插件我能看到的是某种滑块,这不是我期待的。
理想的插件应该显示网页上的所有(缩略图)图像,并且应该包含一个和previous按钮。这也将是很好,如果能在图像上悬停你的鼠标光标后,显示的图像的名称。

The second question I have is about a nice JQuery gallery. Pretty much all the plugins I can find are some kind of slider, which is not what I am looking for. The ideal plugin should show all (thumbnail) images on a page, and should contain next and previous buttons. It would also be nice if the name of an image could be shown after hovering your mouse cursor over the image.

希望有人能回答我的问题,

Hopefully someone can answer my questions,

在此先感谢

推荐答案

您可以使用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#)图像列表概述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆