Vous êtes sur la page 1sur 2

internal partial class _Default : System.Web.UI.

Page
{

protected void Page_Load(object sender, System.EventArgs e)


{
lblPageLoadTime.Text = "This page was loaded at: " +
System.DateTime.Now.ToString();
GenerateUploadForm();
}

protected void GenerateUploadForm()


{
// if querystring parameter "MODE" is set to "IFRAME"
//then just display file upload panel (pnlFileUpload) and hide
everything else
string mode = Request.QueryString["MODE"];
if (! (mode == "IFRAME"))
{
return;
}
pnlAjax.Visible = false;
pnlIFrame.Visible = false;
lblPageLoadTime.Visible = false;
pnlFileUpload.Visible = true;
if (! IsPostBack)
{
Session["UploadedDocumentsList"] = null;
}
}

protected void btnUploaded_Click(object sender, System.EventArgs e)


{
if (Session["UploadedDocumentsList"] == null)
{
return;
}
// display list of files uploaded in the listbox
ArrayList filesArray = (ArrayList)(Session["UploadedDocumentsList"]);
lstFilesList.DataSource = filesArray;
lstFilesList.DataBind();
}

protected void btnUpload_Click(object sender, System.EventArgs e)


{
// when upload button is clicked, save the filename to the session
if (! fileTestUpload.HasFile)
{
return;
}
ArrayList filesArray = null;
// create new arrayList for storing filenames if it does not already
exist
if (Session["UploadedDocumentsList"] == null)
{
filesArray = new ArrayList();
}
else
{
filesArray = (ArrayList)(Session["UploadedDocumentsList"]);
}
filesArray.Add(fileTestUpload.FileName);
Session["UploadedDocumentsList"] = filesArray;
// the following code triggers upload completion event in client side
ClientScript.RegisterStartupScript(Page.GetType(), "Upload Completed",
"window.parent.iFrame_OnUploadComplete();", true);
}

override protected void OnInit(EventArgs e)


{
base.OnInit(e);

//INSTANT C# NOTE: Converted event handler wireups:


this.Load += new System.EventHandler(Page_Load);
btnUpload.Click += btnUpload_Click;
}

Vous aimerez peut-être aussi