In the past two days, I tried to write a demo of AjaxToolkit: AsyncFileUpload. It has an OnClientUploadComplete attribute that can be associated with client JS, so you can write OnClientUploadComplete="uploadComplete", and then define the uploadComplete method:
function uploadComplete(sender, e) {
//Do something here...
}
But, how to get the uploaded file information from e? In addition to looking at the source code of AjaxControlToolkit, you can also use JS:
function uploadComplete(sender, e) {
var ret = "Properties:n";
for (var prop in e) {
var val = e[prop];
if (typeof (val) === "function") {
ret = (prop "()");
}
else {
ret = prop ": " val;
}
ret = ";n";
}
alert(ret);
}
Result:
This makes it very clear.
The concept of "associative array" in JS is used here. The attributes of a JS object (including methods, which can also be considered as attributes) are stored in its associative array. Through for...in... Can be traversed to.
Regarding associative arrays, we can use this:
var dog = new Object();
dog.id = 1;
dog["name"] = "Gougou";
alert("id: " dog["id"] ", name" dog.name);
Get: "id: 1, name: Gougou"
This article is original, please indicate when reprinting: from Freeway —— cnBlogs