如何清除具有Runat属性的输入类型文件HTML控件的内容 [英] How Do I Clear The Contents Of Input Type File Html Control That Is Having Runat Attribute

查看:112
本文介绍了如何清除具有Runat属性的输入类型文件HTML控件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..!

我的aspx页面中有一个输入type ="file"控件.像下面一样,

Hi..!

I have a input type="file" control in my aspx page. Like Below,

<input type="file" runat ="server" class="_5f0v" title="Choose a file to upload" accept="image/*" name="file" id="File1"  onchange="UploadFileNow()" clientidmode="Static"  />

And UploadFileNow() javascript method is like below,

        function UploadFileNow() {

            var value = $("#File1").val();

            if (value != '') {

                document.forms[0].submit();

            }

        };

Now, After Uploading the file to the server side, im using registerCLient script Like below, 

ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "Script", "clearFile();", True)

And, Here is clearFile() Function, 

 function clearFile() {
            
            var control = $("#File1");
            
            control.replaceWith(control = control.clone(true)); 
}



但是,文件内容没有被清除..!

有人可以帮助我摆脱这个问题吗?

谢谢.. !!



But, the file contents are not getting cleared..!

can some one help me to get out of this problem?

Thank You..!

推荐答案

(" ).val(); 如果(!= ' '){ document.forms [ 0 ].submit(); } }; 现在,将文件上传到服务器端后,使用 registerCLient脚本,如下所示, ScriptManager.RegisterClientScriptBlock(Me,Me.GetType()," clearFile();",True) 而且,这里 is clearFile()函数, 函数clearFile(){ var 控件=
("#File1").val(); if (value != '') { document.forms[0].submit(); } }; Now, After Uploading the file to the server side, im using registerCLient script Like below, ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "Script", "clearFile();", True) And, Here is clearFile() Function, function clearFile() { var control =


(" ); control.replaceWith(control = control.clone( true )); }
("#File1"); control.replaceWith(control = control.clone(true)); }



但是,文件内容没有被清除..!

有人可以帮助我摆脱这个问题吗?

谢谢!!!



But, the file contents are not getting cleared..!

can some one help me to get out of this problem?

Thank You..!


<pre lang="c#">
var control =


这篇关于如何清除具有Runat属性的输入类型文件HTML控件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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