<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 language="javascript" type="text/javascript">
function change() {
var fileName = document.getElementById("FileUpTrolley").value;
if (fileName == "")
return;
var exName = fileName.substr(fileName.lastIndexOf(".") + 1).toUpperCase()
if (exName == "JPG" || exName == "BMP" || exName == "GIF") {
document.getElementById("Img1").src = fileName;
}
else {
alert("请选择正确的图片文件");
document.getElementById("FileUpTrolley").value = "";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpTrolley" runat="server" οnchange="change()" />
<asp:Image ID="Img1" runat="server" Height="200" Width="200" />
</div>
</form>
</body>
</html>