显示FileUpLoad控件所浏览的图片?

今天编程的时候我想用
 this.Image1.ImageUrl =FileUpload1.PostedFile.FileName;
显示FileUpLoad控件所浏览的图片,可是显示不出来.
在网上查了之后,发现了这样一段代码:
"源"代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CarSignStory.aspx.cs" Inherits="后台管理_CarSignStory" %>

<!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>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
  
<asp:FileUpload ID="FileUpload1" runat="server" />
  
<img id="img" style="display:none"/>
    
</div>
    
</form>
</body>
</html>

.cs文件代码:
protected void Page_Load(object sender, EventArgs e)
    
{
        FileUpload1.Attributes.Add(
"onchange""document.getElementById('img').src=this.value;document.getElementById('img').style.display='block';");   

    }
posted @ 2007-10-09 10:32  @天天  阅读(1935)  评论(2)    收藏  举报