在页面上放入一个上传控件和一个图片控件.
<asp:FileUpload ID="FileUpload1" runat="server" onpropertychange="show(this.value)"/>
<asp:Image ID="Image1" runat="server" />
在上传控件中写onpropertychange="show(this.value)"事件并调用js中的show函数并将自身的参数传进js.
<script type="text/javascript">
function show(id)
...{
document.getElementById("Image1").src=id;
}
</script>
Ie6,Ie7测试通过(注要通过滤器实现)
<div id="divview" style="filter : progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);WIDTH: 166px; HEIGHT: 190px">
<!--用于显示图片-->
</div>
<asp:FileUpload ID="FileUpload3" runat="server" onpropertychange="show1(this.value)"/>
<script type="text/javascript">
function show1(upimg)
...{
var dd=document.getElementById("divview");
dd.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = upimg;
dd.style.width = 166;
dd.style.height = 190;
dd.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = scale;
}
</script>