Image1的图像预览? [英] image preview at Image1 ?

查看:74
本文介绍了Image1的图像预览?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能我正在尝试吗?









我的jquery



are it's possible which i'm trying ?




my jquery

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js">
        function showimagepreview(input) {
            if (input.files && input.files[0]) {
                var filerdr = new FileReader();
                filerdr.onload = function (e) {
                    $('#Image1').attr('src', e.target.result);
                }
                filerdr.readAsDataURL(input.files[0]);
            }
        }
    </script>







fileupload1






fileupload1

<asp:FileUpload ID="FileUpload1" runat="server"
           onchange="showimagepreview(this)"/>









i想预览Image1



请帮我生成上传图片预览





i want preview at Image1

please help me to generate preview of upload image

推荐答案

('#Image1')。attr('src',e.target.result);
}
filerdr.readAsDataURL(input.files [0]);
}
}
< / script >
('#Image1').attr('src', e.target.result); } filerdr.readAsDataURL(input.files[0]); } } </script>







fileupload1






fileupload1

<asp:FileUpload ID="FileUpload1" runat="server"
           onchange="showimagepreview(this)"/>









i想预览Image1



请帮我生成上传图片预览





i want preview at Image1

please help me to generate preview of upload image


问题



问题是, Image1 未声明控件页面。

解决方案



脚本



Problem


The problem is, Image1 Control is not declared on the Page.

Solution


Script


<script type="text/javascript">
    function showimagepreview(input) {
        if (input.files && input.files[0]) {
            var filerdr = new FileReader();
            filerdr.onload = function (e) {


' #<%= Image1.ClientID%>')。attr(' < span class =code-string> src',e.target.result);
}

filerdr.readAsDataURL(input.files [ 0 ]);
}
}
< / script >
('#<%= Image1.ClientID %>').attr('src', e.target.result); } filerdr.readAsDataURL(input.files[0]); } } </script>



HTML




HTML


<asp:FileUpload ID="FileUpload1" runat="server" onchange="showimagepreview(this)" />
<img id="Image1" alt="uploaded image preview" />


这篇关于Image1的图像预览?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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