Home > Article > Web Front-end > asp.net server control does not refresh the page problem_html/css_WEB-ITnose
I made a picture upload function. After clicking "Upload", the entire page was refreshed, and some other The value in the html tag is gone. How can I prevent the entire page from refreshing after clicking the server button?
I tried the online method, but it didn’t work.
UpdatePanel
The control to be dynamically updated is placed inside this tag. Your file control should be placed inside
How to write upload_Click
UpdatePanel
The control to be dynamically updated is placed in this tag. Your file control should be placed in it
After putting it in, I clicked "Upload" and it still refreshed. upload_Click contains:
if (fileload.PostedFile.FileName == "")
} !fileload.HasFile)
{
string filepath = fileload.PostedFile.FileName;
string filename = filepath.Substring(filepath.LastIndexOf("\") 1);
//int size = fileload.PostedFile.ContentLength;
if (fileload.FileName.Split('.')[1] == "jpg" || fileload.FileName.Split('.')[1] == "png")
\" filename;
fileload.PostedFile.SaveAs(serverPath);
MessageBox.Show("Upload successful!");
else
Please upload pictures in jpg or png format! “); > ajax form
You can’t upload images to the server using Ajax
It’s not ajax
You can upload it with this, and use Request['input name'] in the background to get the uploaded image
ajax form
You can’t upload images to the server using Ajax
Not ajax
You can use this Uploaded, use Request['input name'] in the background to get the uploaded image
This should only get the name or path of the image, but not the image file. According to what you mean, the image should be passed as data. In the past?Refer to this
http://www.cnblogs.com/panshengqiang/p/3195631.html
ajax form
You cannot upload images to the server using Ajax
Not ajax
You can upload using this, use Request['input name'] in the background Get the uploaded image
Refer to this
http://www.cnblogs.com/panshengqiang/p/3195631.html
ajax form