在面板上显示图像

时间:2012-09-19 10:15:36

标签: c# asp.net

我在文件夹的面板中水平显示缩略图,我也希望当我点击缩略图时,该缩略图的原始图像将显示在缩略图下方的第二个面板中。

ASPX代码是:

<asp:Panel ID="panelIDtb" BorderColor="Red" BorderStyle="Solid" BackColor="GrayText" BorderWidth="1px" Width="1000px" ScrollBars="Horizontal" runat="server" Height="130px">
    <asp:Repeater
        id="RepeaterImage"
        runat="server">
        <ItemTemplate>
            <asp:Image id="Image1" Width="100px" Height="100px"
                ImageUrl='<%# Container.DataItem %>' Runat="server" />
        </ItemTemplate>
    </asp:Repeater>
</asp:Panel>
背后的代码是:

public partial class _Default : System.Web.UI.Page
{
    void Page_Load()
    {
        if (!Page.IsPostBack)
        {
            RepeaterImage.DataSource = GetPhotos();
            RepeaterImage.DataBind();
        }
    }

    public List<String> GetPhotos()
    {
        List<string> photos = new List<string>();
        string photoPath = MapPath("~/myimages/images_tn");
        string[] files = Directory.GetFiles(photoPath);
        foreach (string photo in files)
            photos.Add("~/myimages/images_tn/" + Path.GetFileName(photo));
        return photos;
    }
}

我该怎么做?

0 个答案:

没有答案
相关问题