using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using ETS_Data; namespace ETS_WS.WebUserControls { public partial class mod_singleFileUpload : System.Web.UI.UserControl { /// /// evento richiesta salvataggio files /// public event EventHandler eh_fileUploaded; /// /// area temp x salvataggio files /// protected string scratchArea = @"C:\Temp\"; /// /// caricamento componente /// /// /// protected void Page_Load(object sender, EventArgs e) { fileUplAsync.UploadedComplete += new EventHandler(fileUplAsync_UploadedComplete); } /// /// imposta testo button x switch visibilità /// public string btnText { set { btnShowSostFile.Text = value; } } /// /// button abilitato /// public bool btnEnabled { set { btnShowSostFile.Enabled = value; } } /// /// area dove salvare i file caricati async /// public string tempArea { get { return scratchArea; } set { scratchArea = value; } } /// /// nome del file caricato /// public string newFileName { get { string answ = ""; try { answ = utils.obj.StringSessionObj(string.Format("{0}_newFileName", this.UniqueID)); } catch { } return answ; } set { utils.obj.setSessionVal(string.Format("{0}_newFileName", this.UniqueID), value); } } /// /// fine caricamneto file, salvo in area temp! /// /// /// void fileUplAsync_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { if (fileUplAsync.HasFile) { newFileName = fileUplAsync.PostedFile.FileName; fileUplAsync.SaveAs(MapPath(scratchArea +@"\"+ newFileName)); } if (eh_fileUploaded != null) { eh_fileUploaded(this, new EventArgs()); } } } }