I am using this Ajax upload code. it is working fine however, I want to be able to add the value of the textbox to the file name before I save all files. I am not able to capture the value of the text box into the file name and save the file.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="AjaxUpload.aspx.cs" Inherits="contactDirectory.demo.AjaxUpload" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div align="center">
<asp:TextBox ID="txtName" runat="server" AutoPostBack="False"></asp:TextBox>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
AllowedFileTypes="jpg,jpeg,png,gif,doc,pdf,xls,docx,xlsx"
MaximumNumberOfFiles="10"
OnUploadComplete="File_Upload"
onUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll"
onUploadedStart="AjaxFileUpload1_UploadStart"
Width="500px" />
</div>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
namespace contactDirectory.demo
{
public partial class AjaxUpload : System.Web.UI.Page
{
string filename = "";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void File_Upload(object sender, AjaxFileUploadEventArgs e)
{
filename = e.FileName + txtName.Text;
string strDestPath = Server.MapPath("~/documents/" + filename);
AjaxFileUpload1.SaveAs(strDestPath + filename);
}
protected void AjaxFileUpload1_UploadCompleteAll(object sender, AjaxFileUploadCompleteAllEventArgs e)
{
}
protected void AjaxFileUpload1_UploadStart(object sender, AjaxFileUploadEventArgs e)
{
}
}
}