我正在使用<asp:FileUpload>
和<asp:button>
控件上传文件,但我想在没有回发的情况下进行。单击按钮时,我执行以下代码。
protected void btnUpload_Click(object sender, EventArgs e)
{
string strFileName = Path.GetFileName(FileUpload1.FileName); //fileupload1 is the <asp:fileupload ID
FileUpload1.SaveAs(Server.MapPath("~/UploadFile/" + strFileName + ""));
imgUpload.ImageUrl = "../UploadFile/" + strFileName + ""; //imgupload is the <img ID on which I am showing the image after upload
imgUpload.Visible = true;
}
上传文件后,我在项目解决方案中显示指定文件夹中保存的图像,但是在单击上传按钮时,整个页面都会被加载,我不希望在单击上传按钮时回发。