.aspx :
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<ajaxToolkit:ToolkitScriptManager runat="Server" EnableScriptLocalization="true" EnableScriptGlobalization="true" />
<asp:Label runat="server" ID="myThrobber" Style="display: none;">
<img align="absmiddle" alt="" src="../Images/uploading.gif"/>
</asp:Label>
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1"
runat="server"
ThrobberID="myThrobber"
ContextKeys="fred"
AllowedFileTypes="jpg,jpeg"
MaximumNumberOfFiles="10"
OnUploadComplete="AjaxFileUpload1_OnUploadComplete"
/>
.cs:
using AjaxControlToolkit;
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file)
{
//上传服务器处理类
FilesHelper ufh = new FilesHelper();
string sFileName = ufh.GetFileTempUrl(file.ContentType);
AjaxFileUpload1.SaveAs(Server.MapPath(sFileName));
if (Session["AfuFiles"] != null)
{
sFileName = sFileName + "," + Session["AfuFiles"];
}
Session["AfuFiles"] = sFileName;
}
提交按钮处理事件:
string sAfuFileAppend = string.Empty;
if (Session["AfuFiles"] != null)
{
sAfuFileAppend = Session["AfuFiles"].ToString();
Session["AfuFiles"] = null;
}