在知道JQUREY和微软集成的消息后,在项目里面就开始尽量使用JQUERY了,这个DEMO是一个示例。主要文件两个:
  ajaxUpFile.ashx     服务端处理
  Default.aspx     用户提交
  下面贴出主要代码:
  JS部分代码如下
 function TestUp()    {        ajaxFileUpload("FileUpload1");    }        function ajaxFileUpload(obfile_id)    {    //准备提交处理     $("#loading_msg").html("<img src=/images/DotAjax.gif />");        //开始提交     $.ajax    ({        type: "POST",        url:"ajaxUpFile.ashx",        data:"upfile="+$("#"+obfile_id).val(),        success:function (data, status)        {                        //alert(data);             var stringArray = data.split("|");            if(stringArray[0]=="1")            {                //stringArray[0]    成功状态(1为成功,0为失败)                 //stringArray[1]    上传成功的文件名                 //stringArray[2]    消息提示                 $("#divmsg").html("<img src=/images/note_ok.gif />"+stringArray[2]+"  文件地址:"+stringArray[1]);                $("#filepreview").attr({ src:stringArray[1]});            }                        else            {                //上传出错                 $("#divmsg").html("<img src=/images/note_error.gif />"+stringArray[2]+"");            }                                   $("#loading_msg").html("");         },        error:function (data, status, e)        {            alert("上传失败:"+e.toString());        }     });     return false;//.NET按钮控件取消提交 } 
转载:http://www.sunxin.org/forum/thread/16762.html
感觉还不错,与大家分享。