Reputation: 447
I have a form that requires a file to be uploaded as well as additional data (name, etc...) with validation on these fields. When an error occurs, the file has to be re-uploaded. Is there a way to keep the file after a validation error occurs? This is built in C# .NET.
Tried to google this but nothing helpful came up.
Thanks in advance!
Upvotes: 1
Views: 2016
Reputation: 1045
I'm taking a bit of a guess at what you're doing since you really can't persist a file... are you simply using a fileupload dialog box and taking it from there? If so, it's typical to put the file/path obtained from the dialog in a txt field, then do your post (upload) with a separate button.
This scenario assumes you want to persist the path/file name, but not the actual file.
Upvotes: 1
Reputation: 400
You can't genually persist the file because of Security Purpose.. If page is posted and validation error occured, check for a file using the .PostedFile property, and if one exists, save it to a temp file. In Session, store a reference to the temporary file. (use javascript)
.PostedFile is a property of the FileUpload control.
Also, during my google research, I found AJAX RadControl related to your question..
http://www.telerik.com/help/aspnet-ajax/asyncupload-persist-uploaded-files.html
Upvotes: 5