AjaxControlToolkit
<asp:TextBox ID="txtWorkerId_Upload" runat="server" CssClass="form-control" ReadOnly="true"></asp:TextBox>
<ajaxToolkit:AjaxFileUpload ID="afuPFDocument" runat="server" MaximumNumberOfFiles="1" AllowedFileTypes="pdf" OnUploadComplete="afuPFDocument_UploadComplete" />
服务器端事件
protected void afuPFDocument_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string[] FileExtension = e.FileName.Split('.');
string FileName = txtWorkerId_Upload.Text + "_PFDocument." + FileExtension[1];
afuPFDocument.SaveAs(Server.MapPath("~/WorkerDocuments/") + FileName);
}
文本框中有WorkerId =&#39; 27645&#39; 但文件上传为&#39; _PFDocument.pdf&#39;。在上传的文件中缺少WorkerId。 在此,我想根据文本框数据重命名上传的文件。