Filefield Postback woes
-
I have recently created a form that gives the user the option of filling out certain information in either text fields, or as file attachments, or a combination of both. The problem i am runninginto, is that if the user clicks the browse button and selects a file, then hits any of the other controls that do a postback, the selected file is lost. I have tried using
this.filefield.EnableViewState = true
to see if that would keep, but it doesnt. i also have not been able to progromatically assign a value or a PostedFile.Filename. the page errors out and says that they are not "settable" (gotta love "msenglish") if i could grab the information and pass it to a hidden field, or allow the viewstate to hold it, that would be great. My only other recourse is to make it so that selecting files to upload is the LAST thing that can be done before submission, but that is a pain in and of itself, and doesnt do doodily squat for the user if they have to go back and redo something before submission. they would have to start any files they wanted to upload all over again... Note: I cant turn off autopostback for the controls that use it, it is integral to how the forms work. Yes, I am the highly suggestable type. -
I have recently created a form that gives the user the option of filling out certain information in either text fields, or as file attachments, or a combination of both. The problem i am runninginto, is that if the user clicks the browse button and selects a file, then hits any of the other controls that do a postback, the selected file is lost. I have tried using
this.filefield.EnableViewState = true
to see if that would keep, but it doesnt. i also have not been able to progromatically assign a value or a PostedFile.Filename. the page errors out and says that they are not "settable" (gotta love "msenglish") if i could grab the information and pass it to a hidden field, or allow the viewstate to hold it, that would be great. My only other recourse is to make it so that selecting files to upload is the LAST thing that can be done before submission, but that is a pain in and of itself, and doesnt do doodily squat for the user if they have to go back and redo something before submission. they would have to start any files they wanted to upload all over again... Note: I cant turn off autopostback for the controls that use it, it is integral to how the forms work. Yes, I am the highly suggestable type.This control is extremely protected. What I mean by this is that you cannot set the filename programatically (to avoid any type of "hacking"). The user is the only one that can select the filename. I have encountered the exact same problem, and never came to a solution. This may not be possible with the filefield control. There is also a free control available from metabuilders which brings all the client side options to the server side. You may be interested in trying it out. http://www.metabuilders.com/Tools/FileUpload.aspx[^] Please post your solution if you find one. Jon G www.Gizmocoder.com
-
This control is extremely protected. What I mean by this is that you cannot set the filename programatically (to avoid any type of "hacking"). The user is the only one that can select the filename. I have encountered the exact same problem, and never came to a solution. This may not be possible with the filefield control. There is also a free control available from metabuilders which brings all the client side options to the server side. You may be interested in trying it out. http://www.metabuilders.com/Tools/FileUpload.aspx[^] Please post your solution if you find one. Jon G www.Gizmocoder.com