.net上传了图片怎么鼠标经过图片能预览呢。51模板集介绍大家怎么预览图片。直接给大家举例,下面的代码很详细:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Web.WebForm1" %>
<!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>
<meta http-equiv="Content-Type " content="text/html; charset=gb2312 " />
<title>无标题文档 </title>
<style>
.item
{
width: 80px;
height: 20px;
text-align: center;
float: left;
border: 1px #000000 solid;
}
</style>
<title>Preview Image In FileUpload</title>
<%--CSS--%>
<style type="text/css">
#newPreview{
FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
}
</style>
</head>
<body>
<%--JavaScript--%>
<script language="javascript" type="text/javascript">
function PreviewImg(imgFile)
{
var newPreview = document.getElementById("newPreview");
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
newPreview.style.width = "80px";
newPreview.style.height = "60px";
}
</script>
<form id="form1" runat="server">
<div>
<%--添加onchange事件--%>
<asp:FileUpload ID="FileUpload1" runat="server" onchange="PreviewImg(this)" />
</div>
<%--建立一个div来存放预览--%>
<div id="newPreview"></div>
</form>
</body>
</html>
红色区域的文字是关键,这里面也做了备注。这样就实现了。net上传图片之后预览图片的功能呢
关于本站 | 网站地图 | 手机版 | XML地图 | 反馈 | 版权申明 皖ICP备13006370号-1