Home » Category » Web Forms

Web Forms: HtmlInputFile viewstate

102| Mon, 31 Dec 2007 17:03:00 GMT| ravivulli| Comments (5)
Hi!

Is there any way to maintain viewstate of a value that's selected into an
HTMLInputFile field? In other words, is it possible to maintain the
"selected" file path between post events?

Thanks to all who answer!

Ravi Vulli

Keywords & Tags: htmlinputfile, viewstate, web, forms

URL: http://dotnet.itags.org/web-forms/134952/
 
«« Prev - Next »» 5 helpful answers below.
I think viewstate won't work on this control because the W3C specification for an InputFile control states that the server cannot pre-set a value for this control. (that's basically all Viewstate does--it pre-populates the control with its postback value) The reason is security. If it were possible to pre-populate the value of the control, then it would be possible for a server to grab any file it wanted from a user's machine.

jimrossmvp | Mon, 31 Dec 2007 17:05:00 GMT |

Jim,
Thanks for the reply. Is there any work arround to acheive this?

ravivulli | Mon, 31 Dec 2007 17:06:00 GMT |

Not that I can think of. Unless you could use a script on the client.

jimrossmvp | Mon, 31 Dec 2007 17:07:00 GMT |

Jim,
Can you provide the client side script.

Thanks.
Ravi

ravivulli | Mon, 31 Dec 2007 17:08:00 GMT |

In thinking about it, I doubt a client side script would work, either. You could check the W3C specs for the "input" control when type=file, but I'll bet the value is read-only for scripting. Otherwise you have the same security hole.

jimrossmvp | Mon, 31 Dec 2007 17:09:00 GMT |

Web Forms Hot Answers

Web Forms New questions

Web Forms Related Categories