100 分!不想让页面刷新,如何才能把这个功能改成用 javascript 实现呢,这样就不用刷新页面了

100 分!!!不想让页面刷新,怎么才能把这个功能改成用 javascript 实现呢,这样就不用刷新页面了!


功能截图在这里,只要看一下就能全明白我的意思:

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   ,存放多个填加的   FindFile

static   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   较容易实现
    }
}




------解决方案--------------------
<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;