单击asp:FileUpload按钮时是否可以触发OnClick
事件?
问问题
1682 次
2 回答
1
您可以使用闪存代码,它将文件上传器作为可点击的按钮。但为此,您需要下载 swfupload.swf 文件。
<input type="file" id="uplaodExcel" name="uplaodExcel" />
以下是javascript代码:
Sys.Application.add_init(function () {
HideError();
$("#uplaodExcel").makeAsyncUploader({
upload_url: 'EventName',//Event you want to occur on click
flash_url: '../Scripts/swfupload.swf',//flash file path that you download
button_image_url: '@Url.Content("~/Content/blankButton.png")',// for button style
file_size_limit: "10MB",
file_types: "*.XLS; *.xlsx", //File extension you can provide any
disableDuringUpload: 'INPUT[type="submit"]',
upload_success_handler: function (file, server_data, receivedResponse) {
var data = "";
try {
// you can add your code here
} catch (e) { }
}
});
});
于 2012-11-06T13:47:26.673 回答