Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi..!

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

C#
<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..!
Posted
Updated 6-Feb-14 19:38pm
v2

1 solution

<pre lang="c#">
var control = $("#File1");


add id with
var control=document.getElementById("<%=File1.ClientID%>");
 
Share this answer
 
Comments
Tuduru Sai Krishna 7-Feb-14 7:54am    
I'm using clientIdMode="static", so i hope, using "File1.ClientID" is not required

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900