[code=HTML][/c<%@ Page Language="C#" AutoEventWireup="true" CodeFile="userupdown.aspx.cs" Inherits="user_userupdown"  EnableViewState="true" %><%@ Register Src="../Controls/usermenu.ascx" TagName="usermenu" TagPrefix="uc3" %><%@ Register Src="../Controls/HeadControl.ascx" TagName="HeadControl" TagPrefix="uc1" %>
<%@ Register Src="../Controls/footer.ascx" TagName="footer" TagPrefix="uc2" %><!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>
    <link rel ="stylesheet" type="text/css" href="../App_Themes/top.css" />
    <link rel ="stylesheet" type ="text/css" href ="../App_Themes/usermange.css" />
    
    
</head>
<body>    <form id="form1" runat="server">
    <script type ="text/javascript">
    
    function preview()
    {
      var imag=document.getElementById("divimg");
    imag.style.display="block";
    var updown=document.getElementById("File1");
    imag.src=updown.value;
      }
    
   </script>
    <div>
        <uc1:HeadControl ID="HeadControl1" runat="server"  />
    <div id="usermanger">
    <div class ="left">
        <uc3:usermenu ID="Usermenu1" runat="server" />
    </div>
    <div class ="content">
    <div class="title">上传图片</div>
        <br />
        <div style="width:300px;text-align:left;float:left; clear:left;">
        <asp:Label ID="exe" runat="server" Text="Label" Visible="False"></asp:Label><br />
        <input id="File1" runat="server" name="file" type="file" style="width: 321px; height: 21px" onchange="preview();" /><br />
            <img  id="divimg" style="display :none; width:100px;height:100px;"alt ="预览" src=""  /><br />
  ode]

解决方案 »

  1.   

    你看下生成的 HTML源代码, input的name变成了File1 
    另外预览本地文件涉及安全问题
      

  2.   

    上面的是因为实现不了 ,然后改了很多次后的
    现在发现在的:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="userupdown.aspx.cs" Inherits="user_userupdown"  EnableViewState="true" %><%--<%@ Register Src="../Controls/usermenu.ascx" TagName="usermenu" TagPrefix="uc3" %><%@ Register Src="../Controls/HeadControl.ascx" TagName="HeadControl" TagPrefix="uc1" %>
    <%@ Register Src="../Controls/footer.ascx" TagName="footer" TagPrefix="uc2" %>--%><!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>
        <link rel ="stylesheet" type="text/css" href="../App_Themes/top.css" />
        <link rel ="stylesheet" type ="text/css" href ="../App_Themes/usermange.css" />
        
        
    </head>
    <body>    <form id="form1" runat="server">
        <script type ="text/javascript">
        
        function preview()
        {
          var imag=document.getElementById("divimg");
        imag.style.display="block";
        var updown=document.getElementById("File1");
        imag.src=updown.value;
          }
        
       </script>
        <div>
          <%-- <uc1:HeadControl ID="HeadControl1" runat="server"  />--%>
        <div id="usermanger">
        <div class ="left">
          <%-- <uc3:usermenu ID="Usermenu1" runat="server" />--%>
        </div>
        <div class ="content">
        <div class="title">上传图片</div>
            <br />
            <div style="width:300px;text-align:left;float:left; clear:left;">
            <asp:Label ID="exe" runat="server" Text="Label" Visible="False"></asp:Label><br />
            <input id="File1" runat="server" name="file" type="file" style="width: 321px; height: 21px" onchange="preview();" /><br />
                <img  id="divimg" style="display :none; width:100px;height:100px;"alt ="预览" src=""  /><br />
      
           图片名字:<asp:TextBox ID="picture_name" runat="server" Width="127px"></asp:TextBox><br />
           <br />
           分 &nbsp; &nbsp; &nbsp; 类:大类&nbsp;
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
           </asp:DropDownList>
           小类 &nbsp;
                <asp:DropDownList ID="DropDownList2" runat="server" Width="75px">
           </asp:DropDownList><br /><br />
          <div style="float:left;margin-top:5px;">是否允许评论:&nbsp;&nbsp;&nbsp;</div><asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" Width="118px">
              <asp:ListItem Value="1" Selected="True">是</asp:ListItem>
              <asp:ListItem Value="0">否</asp:ListItem>
          </asp:RadioButtonList>
          <br />
           关 键 &nbsp;字:<asp:TextBox ID="picture_keyword" runat="server" Width="218px"></asp:TextBox><br />
           <br />
           简 &nbsp; &nbsp; &nbsp; 介:<asp:TextBox ID="picture_details" runat="server" TextMode="MultiLine" Height="90px" Width="320px" ></asp:TextBox><br />
           <br />
           来 &nbsp; &nbsp; &nbsp; 自:<asp:TextBox ID="picture_source" runat="server" Width ="220px"></asp:TextBox><br/><br />
            <br /><br />
            </div><div style="color:Red;font-weight:bold;float:right;" >(请勿上传色情或违法反动图片)
    <ol style="color:Black;font-weight:lighter;"><li>上传图片最大为1MB,图片过大请ps后再传</li>
    <li>图片的最长为300px,超出部份将被截除</li>
    <li>上传的新图片会很快在网站相应分类下显示</li>
    <li>您的上传,表示您默认同意我们的内容协议</li></ol></div> 
    <p style="text-align:center; clear:both;">
                <asp:Button ID="Button6" runat="server" Text="确定上传"  />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input  id="Reset1" type="reset" value="取消上传" /></p></div></div>
            <%--<uc2:footer ID="Footer1" runat="server" />--%>
        </div>
        </form>
    </body>
    </html>我是想在img标签里显示file 控件路径图片!可是不知道为什么不行??在html 页面里 js 就能实现??
      

  3.   

    <script type ="text/javascript"> 
         
        function preview(obj) 
        { 
          var imag=document.getElementById("divimg"); 
        imag.style.display="block"; 
        imag.src=obj.value; 
          } 
         
        </script> <input id="File1"  name="file" type="file" style="width: 321px; height: 21px" onchange="preview(this);" /> <br /> 
                 <img  id="divimg" style="display :none; width:100px;height:100px;"alt ="预览" src=""  /> <br /> 
      

  4.   

    ls
    其实file只是为只读而已,这样不需要考虑安全性,只有我们给file value时才会出错.
    lz
    代码测试过没有问题的呢.
      

  5.   

    去掉runat="server",参考楼上的楼上
      

  6.   

    value  value  对于按钮、重置按钮和确认按钮:定义按钮上的文本。对于图像按钮:定义传递向某个脚本的此域的符号结果。对于复选框和单选按钮:定义 input 元素被点击时的结果。对于隐藏域、密码域以及文本域:定义元素的默认值。注释:不能与 type="file" 一同使用。注释:与 type="checkbox" 和 type="radio" 一同使用时,此元素是必需的。
      

  7.   

    我都要崩溃了 为什么在html 里面可以运行 在aspx 里面就不可以
    为什么在ie 里面布局好好的  在火狐里面 却连竖直滑条都消失了
      

  8.   

    关于布局的IE和火狐的兼容性,你最好在每个层的样式里面加一句 float:left
    这样两者的布局基本就不会有差别