Menu ▼



Posted By :
avatarmrkraju
Total Views : 514

Reset or clear the value of fileuplopad control using jquery

This example will shows you how to reset/clear the value of asp.net fileupload control or html input type file using jquery.

Syntax:
control.replaceWith( control = control.clone( true ) );

Example:


Code:
function resetFileControl() {
    var control = $("#fupexample");
    control.replaceWith(control = control.clone(true));
}

Source Code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script language="javascript">
        function resetFileControl() {
            var control = $("#fupexample");
            control.replaceWith(control = control.clone(true));
        }
    </script>
</head>
<body>
    <input type="file" id="fupexample" sytle="width:200px;" />
    <input type="button" onclick="resetFileControl();" value="Reset" />
</body>
</html>





comments powered by Disqus


Search dotnetlearners.com