try to set the width to 0 and display a readonly textbox, for example<form runat="server" enctype="multipart/form-data">
<input type="text" name="txt1" readonly>
<input type="file" id="file1" runat="server" style="width:0;border-width:0;" onpropertychange="this.form.txt1.value=this.value">
<asp:Button runat=server Text="submit" OnClick="SubmitForm"/>
</form>
<script language="C#" runat="server">
void SubmitForm(Object sender, EventArgs e)
{
  if (file1.PostedFile.FileName != String.Empty && file1.PostedFile.ContentLength > 0)
  {
    Response.Write(String.Format("{0} is upload,size of {1}", file1.PostedFile.FileName, file1.PostedFile.ContentLength ));
  }
}
</script>>>>用什么语句判断输入框里是否为空 on the client, you can use inputFile.value to check, on the server side, check FileName and ContentLength

解决方案 »

  1.   

    一楼的方法很好!判断文本框是否为空://上传文件
    if(flFile.Value.Trim() != "")
    {
        if(flFile.PostedFile == null) //验证文件是否有效的文件
        {
            this.RegisterStartupScript("jsSelFile","<script language=javascript>alert('请正确选择您要上传的文件!')</script>");
    return;
        }
        else
        {
             //你的上传代码。
        }
    }
      

  2.   

    天~~~我都写了我用的是VB.Net,可两位大侠也太.......
      

  3.   

    你应当用客户端脚本去判断,如楼上所说的javascript