如何在一个页面上显示图像并在另一个页面上显示该图像?使用ASP.NET和C#

时间:2014-06-04 18:47:47

标签: c# asp.net image uploading

以下是我上传按钮的代码......

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class Admin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void btnUpload_Click(object sender, EventArgs e)
     {
        if (FileUpload1.HasFile)
        {
            string path = "~/Uploads/" + FileUpload1.FileName;
            FileUpload1.SaveAs(MapPath(path));
        }
     }

protected void Page_PreRender()
    {
        string path = MapPath("~/Uploads/");
        DirectoryInfo dirInfo = new DirectoryInfo(path);
        dlImages.DataSource = dirInfo.GetFiles; <-------- "dlImages" cannot be found
        dlImages.DataBind(); <-------- "dlImages" cannot be found
    }
}

'数据列表“dlImages”存在于Images.aspx页面上,但Admin.aspx上存在上传按钮。基本上我想要实现的是管理员上传图像并将其显示在图像页面上。我怎样才能做到这一点??请和谢谢'

0 个答案:

没有答案