After post back File upload Control not holding the files
After postback fileupload control is not holding the files. i have checked with/without update panel. session using but it is also not displaying the files. plz help.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
bijay BeheraPosted Apr 5, 2016, 2:24 AM
Imtiyaz AnsariPosted Apr 5, 2016, 1:40 AM
//If first time page is submitted and we have file in FileUpload control but not in session// Store the values to SEssion Object
{
Session["FileUpload1"] = FileUpload1;
Label1.Text = FileUpload1.FileName;
}
// Next time submit and Session has values but FileUpload is Blank
else if (Session["FileUpload1"] != null && (! FileUpload1.HasFile))
{
FileUpload1 = (FileUpload) Session["FileUpload1"];
Label1.Text = FileUpload1.FileName;
}
// Now there could be another sictution when Session has File but user want to change the file
// In this case we have to change the file in session object
else if (FileUpload1.HasFile)
{
Session["FileUpload1"] = FileUpload1;
Label1.Text = FileUpload1.FileName;
}