how to upload an image file without any postback in ASP.NET

woodhzbs

New Member
I am uploading a file using the \[code\]<asp:FileUpload>\[/code\] and \[code\]<asp:button>\[/code\] controls but I want to do it without a postback. On button click I execute the following code. \[code\]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;}\[/code\]After uploading the file I am showing the saved image from the specified folder in my project solution, but on clicking the upload button the whole page gets loaded and I don't want the postback on clicking the upload button.
 
Back
Top