如何在Ajax工具包文件uploadcontrol中检查文件是否存在 [英] How to check file exist or not in Ajax toolkit file uploadcontrol

查看:62
本文介绍了如何在Ajax工具包文件uploadcontrol中检查文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我先告诉你我的方案。我正在使用ajax toolkit文件上传控件,点击我的提交按钮我需要检查用户选择的文件是否上传如果没有,则给出错误消息。



我尝试过一种方式,一旦用户选择了文件,上传按钮的可见性即将到来,通过这种方式,我完成了但是现在我发现如果用户选择文件并删除了那个。此时上传按钮即将到来。所以我的验证失败了。



现在我想获取队列容器并循环遍历每个子元素并与该特定div中的remove按钮匹配。



请告诉我,我在做什么是对?并建议我实现这一目标的方法。

解决方案

你好,



你可以实现 OnClientUploadComplete 处理程序javascript函数。成功上载文件后,在客户端执行此功能。您还可以实现 OnClientUploadError 处理程序,如果文件上传出错,则会调用该处理程序。



更多信息控件可以在这里 [ ^ ]。



更新:您可以使用以下代码检索单个文件名。你如何调用它取决于你。

  var  ctrlId = ' <%= AjaxFileUpload1.ClientID%>'; 


' span.filename'' #' + ctrlId).each( function (){
alert(


this )。text());
});



问候,


Hi all,
Let me first tell you my scenario.I am using ajax toolkit file upload control and on click of my submit button i need to check whether the file selected by the user is uploaded or not and give a error message if not.

I tried a way that once the file is selected by user then upload button visibility is coming ,by that way i done that.but now i found if user select the file and removed that.at this point also the upload button is coming .So my validation got failed.

Now i thought of getting the queue container and loop through each and every child elements and match with the remove button in that particular div.

please tell me that ,what am i doing is right? and suggest me the way to achieve this.

解决方案

Hello,

You can implement OnClientUploadComplete handler javascript function. This function is executed on the client-side after a file is uploaded successfully. You can also implement OnClientUploadError handler which gets called if there is an error in file upload.

More info on the control can be found here[^].

Update: You can use following code to retrieve the individual file names. How do you invoke it is upto you.

var ctrlId = '<%= AjaxFileUpload1.ClientID %>';


('span.filename', '#' + ctrlId).each(function() { alert(


(this).text()); });


Regards,


这篇关于如何在Ajax工具包文件uploadcontrol中检查文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆