当前位置:编程学习 > C#/ASP.NET >>

上传图片之前预览 fileupload

<%@ page language="c#" codefile="default7.asp教程x.cs" inherits="default7" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
      <script type="text/网页特效">
        function showpreview() {
            var filename = document.getelementbyidx('<%=fupimg.clientid%>').value;
            if (filename != "") {
                document.getelementbyidx('<%=imgpreview.clientid%>').src = filename;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
     <div>
        <img id="imgpreview" runat="server" width="230" height="80" src="7.gif" alt="" style="width: 70px; border:1px solid red" />    
        <asp:fileupload id="fupimg" runat="server" width="300" onchange="showpreview()" />
  
    </div>
    </form>
</body>
</html>
但是只能在ie6上使用,其他的需要设置一下才可以
补充:asp.net教程,基础入门
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,