103 lines
2.9 KiB
C#
103 lines
2.9 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// evento richiesta salvataggio files
|
|
/// </summary>
|
|
public event EventHandler eh_fileUploaded;
|
|
/// <summary>
|
|
/// area temp x salvataggio files
|
|
/// </summary>
|
|
protected string scratchArea = @"C:\Temp\";
|
|
/// <summary>
|
|
/// caricamento componente
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
fileUplAsync.UploadedComplete += new EventHandler<AjaxControlToolkit.AsyncFileUploadEventArgs>(fileUplAsync_UploadedComplete);
|
|
}
|
|
/// <summary>
|
|
/// imposta testo button x switch visibilità
|
|
/// </summary>
|
|
public string btnText
|
|
{
|
|
set
|
|
{
|
|
btnShowSostFile.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// button abilitato
|
|
/// </summary>
|
|
public bool btnEnabled
|
|
{
|
|
set
|
|
{
|
|
btnShowSostFile.Enabled = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// area dove salvare i file caricati async
|
|
/// </summary>
|
|
public string tempArea
|
|
{
|
|
get
|
|
{
|
|
return scratchArea;
|
|
}
|
|
set
|
|
{
|
|
scratchArea = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// nome del file caricato
|
|
/// </summary>
|
|
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);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// fine caricamneto file, salvo in area temp!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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());
|
|
}
|
|
}
|
|
}
|
|
} |