1. 当UploaderStyle="Modern" 的方法
function clearContents() {
var AsyncFileUpload = $get("<%=AsyncFileUpload1.ClientID%>");
var txts = AsyncFileUpload.getElementsByTagName("input");
for (var i = 0; i < txts.length; i++) {
if (txts[i].type == "text") {
txts[i].value = "";
txts[i].style.backgroundColor = "white";
}
}
}
window.onload = clearContents;
function UploadComplete(sender, args) {
clearContents();
}
2.当UploaderStyle="Traditional" 的方法
function clearContents() {
var file = $get("<%=AsyncFileUpload1.ClientID%>");
var form = document.createElement('form');
document.body.appendChild(form);
//记住file在旧表单中的的位置
var pos = file.nextSibling;
form.appendChild(file);
form.reset();
pos.parentNode.insertBefore(file, pos);
document.body.removeChild(form);
}
window.onload = clearContents;
function UploadComplete(sender, args) {
clearContents();
}