viewstate for a File Input Control

  • Thread starter Thread starter Robin
  • Start date Start date
R

Robin

On an ASP.Net page that has viewstate enabled.
How do you enable viewstate for a server side file input control?
Currently I have in the HTML view.
<INPUT id="myID" type="file" name="myID" runat="server">
 
no need. the <input type=file> does not use viewstate as there it has no
data to store in viewstate.

-- bruce (sqlwork.com)


| On an ASP.Net page that has viewstate enabled.
| How do you enable viewstate for a server side file input control?
| Currently I have in the HTML view.
| <INPUT id="myID" type="file" name="myID" runat="server">
|
|
 
What is the exact problem ?

By design you'll never be able to persist values in this control for safety
reasons (i.e. the only way to fill this control is to have the user select a
file).

Patrice
 
Is there another asp.net control that can be used to select a file that has
the viewstate option?
 
Hi Robin,

I have seen a solution that uses an input type=file HTML element that is
hidden with a style. Over that is placed a text box and a button. When you
click the button, it clicks the hidden button in the hidden element (using
JavaScript), which pops up the file open dialog box. Once you select the
file, the value attribute of the file upload element is copied to the
textbox, again, using JavaScript. By using this technique you have
ViewState, and a more malleable user interface.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Back
Top