script type="text/javascript"> function PreviewImage(e) { var preview = document.getElementById('image'); if (e.target.files && e.target.files[0]) { var reader = new FileReader(); reader.onload = function (e) { preview.setAttribute('src', e.target.result); } reader.readAsDataURL(e.target.files[0]); } else { preview.setAttribute('src', '/Attachment/Profile/User.png'); } } $(function () { $('#UserProfilePhoto').change(function (e) { PreviewImage(e); }); }); </script>