Maintain state of Fileupload control
How can I maintain state of fileupload control in asp.net
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 5, 2013, 9:34 PM EDT
You have to use Session. Try like this,
if (Session["FileUpload1"] == null && FileUpload1.HasFile)
{
Session["FileUpload1"] = FileUpload1;
}
else if (Session["FileUpload1"] != null && (! FileUpload1.HasFile))
{
FileUpload1 = (FileUpload) Session["FileUpload1"];
}
else if (FileUpload1.HasFile)
{
Session["FileUpload1"] = FileUpload1;
}
Prasenjit DeyRank #6,279 · 271 reputationPosted Oct 6, 2013, 9:31 PM EDT