?
Solved

Persist the value in file uploader in .net

Posted on 2009-05-09
1
Medium Priority
?
255 Views
Last Modified: 2013-11-08
How can the value of Fileuploader persisted on postback in .net
0
Comment
Question by:KaranGupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
clinton_cunningham earned 2000 total points
ID: 24343238
use a hidden field, i've done this plenty for the exact same reason. I hate losing the selected file when my validation catches somthing on postback.

So basically, when a fileupload field is entered, or just before the postback event.
copy the file location into the hidden field. then read and populate the fileupload on IsPostback.

Here's some code:


     
HTML:
 
<div>
             <asp:FileUpload ID="uploadHTMLHiddenField" runat="server"></asp:Label>
 .            <input id="HTMLHiddenField" type="hidden" name="HTMLHiddenField"/>
         </div>
 
 
   protected void Page_Load(object sender, EventArgs e)
        {
 
             // Insert message to the label of the html control hidden
             // field if there is a value in the html hidden field
 
             string message = Request.Form["HTMLHiddenField"];
  
             if (!string.IsNullOrEmpty(message))
            {
                lblHTMLHiddenField.Text = message;
            }
         }
  
         protected void command_that_postsback(object sender, EventArgs e)
         {
  
            HTMLHiddenField.Text = uploadHTMLHiddenField.Text;
  
   
         } 

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question