功能截图在这里,只要看一下就能全明白我的意思:http://www.jilinhome.com/xml/demo1.gif----------------------------------------------------------------------
一个能同时多附件上传的例子:multipleupload.aspx 代码:<INPUT  id="FindFile"  type="file" name="FindFile" runat="server"><asp:button id="AddFile" runat="server" Text="添加附件到附件框"></asp:button><asp:button  id="RemvFile" runat="server"  Text="删除一个附件"></asp:button>
<asp:listbox id="ListBox1" runat="server"></asp:listbox>-------------------------------------------------------对应  multipleupload.aspx.CS 后台代码:
//先定义一个公共变量,ArrayList ,存放多个填加的 FindFilestatic public ArrayList hif = new ArrayList();这个是后台添加附件到  ListBox1 框中的方法private void AddFile_Click(object sender, System.EventArgs e)
{

string listname = System.IO.Path.GetFileName(FindFile.PostedFile.FileName);
if(listname!="")
  {
    hif.Add(FindFile);
    ListBox1.Items.Add(listname);
  }
}以下是循环上传多个附件的方法:foreach(System.Web.UI.HtmlControls.HtmlInputFile HIF in hif)
{
  ....... //略  HIF.PostedFile.SaveAs(baseLocation + UploadFileFullName);}------------------------------------------------------------我现在想把 AddFile_Click 方法改一下,用 javascript 来实现把 findfiel 添加到 listbox 中,这样不会刷新页面,但是原来.CS 文件的这两上方法用 javascript 如何能实现呢?
private void AddFile_Click(object sender, System.EventArgs e)
{

string listname = System.IO.Path.GetFileName(FindFile.PostedFile.FileName);
if(listname!="")
  {
    hif.Add(FindFile); //如果改成用 javascript 来实现,这个要怎么能实现呢?
    ListBox1.Items.Add(listname); //这个用 javascript 较容易实现
  }
}

解决方案 »

  1.   


    在说简单一点就是如何能把:http://www.jilinhome.com/xml/demo1.gif那个 "添加附件到附件框" 和 “点选下面附件框中某一附件删除一个附件” 用 javascript 来实现,在后台 .CS 中完成的话,页面每次都有刷新!不想刷新页面,只能用 javascript 来实现!
      

  2.   

    不大清楚题意,用Ajax应该可以实现。
      

  3.   

    <DIV id="div1">
    <INPUT ID="File1" TYPE="file" NAME="File1" RUNAT="server"><INPUT TYPE="button" VALUE="Button" onclick="javascript:AddFile();">
    <ASP:LISTBOX id="ListBox1" runat="server"></ASP:LISTBOX>
    <ASP:BUTTON id="Button1" runat="server" Text="Button"></ASP:BUTTON></FONT>
    </DIV>
    <SCRIPT language="javascript">
    <!--
     function AddFile()
     {
    var file = document.getElementById("div1").firstChild;
    if(file.value == "")
    {
    alert("请选择文件!");
    return;
    }
    var o = new Option();
    var ary = file.value.split("\\");
    var filename = ary[ary.length-1];
    o.innerText = filename;
    o.value = filename;
    document.getElementById("ListBox1").appendChild(o);

    file.style.display = "none";
    var f = document.createElement("input");
    f.type = "file";
    f.name = "file"
    div1.insertBefore(f,div1.firstChild);

     

     }
    //-->
    </SCRIPT>
      

  4.   


    100 分,我的本意是要给 100 分的,可是提交的时候忘改给分了,它默认是 20 分,我确实是忘了,不过,我一直都是有贴必结的!cpp2017(慕白兄) 可以作证!我会再开一个 100 分,做为补偿的,一起结贴的!
      

  5.   

    cpp2017(慕白兄):你的方法很好,前台一切都 OK 了,我知道你把那些 
    <INPUT ID="File1" TYPE="file" NAME="File1" RUNAT="server"> 都放在了 
    ListBox1 里了,可是当我在 .CS 文件中循环上传的时候,我是这样写的:foreach(System.Web.UI.HtmlControls.HtmlInputFile HIF in this.ListBox1)可是编译的时候 vs.net 报错啊:E:\OfficeAutomation\ParentSendToChild.aspx.cs(249): foreach 语句无法对“System.Web.UI.WebControls.ListBox”类型的变量操作,因为“System.Web.UI.WebControls.ListBox”不包含“GetEnumerator”的定义,或它是不可访问的
      

  6.   

    你FTB的哪个上传文件哪个代码就会明白该怎么去做了
      

  7.   

    路过------------------------
    http://fenglin.xland.cn
    ------------------------
      

  8.   

    呵呵,这跟 ftb 有什么关系啊!
      

  9.   

    用 AJAX  调用.CS的方法实现
      

  10.   

    不用 ajax ,这是 .net 1.1
      

  11.   

    后台用
    HttpFileCollection  files    =  HttpContext.Current.Request.Files;   
    System.Text.StringBuilder  strMsg  =  new  System.Text.StringBuilder();   
    strMsg.Append("上传的文件分别是:<hr  color=red>");   
    try   
    {   
    for(int  iFile  =  0;  iFile  <  files.Count;  iFile++)   
    {   
    HttpPostedFile  postedFile  =  files[iFile];   
    string  fileName,  fileExtension;   
    fileName  =  System.IO.Path.GetFileName(postedFile.FileName);   
    if  (fileName  !=  "")   
    {   
    fileExtension  =  System.IO.Path.GetExtension(fileName);   
    strMsg.Append("上传的文件类型:"  +  postedFile.ContentType.ToString()  +  "<br/>") ;
    strMsg.Append("客户端文件地址:"  +  postedFile.FileName  +  "<br/>");   
    strMsg.Append("上传文件的文件名:"  +  fileName  +  "<br/>");   
    strMsg.Append("上传文件的扩展名:"  +  fileExtension  +  "<br/><hr>");   
    postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("upload/")  +  fileName);   
    }   
    }   
    strStatus.Text  =  strMsg.ToString();   
    // return  true;   
    }   
    catch(System.Exception  Ex)   
    {   
    strStatus.Text  =  Ex.Message;   
    // return  false;   
    }
      

  12.   


    HttpFileCollection  files    =  HttpContext.Current.Request.Files; 不要生搬硬套,不一样的!