when using the radasyncupload in a scenario that you have several steps to complete until the final save can be done AND the upload of the file is not in the final step, you may find yourself in the situation that either you check the file in code behind (and force the postback trigger) or you postpone to the end when really processing the file to check if it's OK.
First option has a drawback that you get the file info in your code behind but at the next postback you have nothing left as the radasyncupload looses its information. Second option has the drawback that you come with comment on missing file or other file problem in a step that does not correspond with the step they uploaded the file.
How to come over this????
Solution: just add a radtextbox (readonly) to your form below the radasyncupload. On client upload you set the value of that textbox. You have a regular required field validator linked to the textbox. If the upload is successful and valid you set the textbox with the filename and the validator passes. If the file upload is not done or invalid the textbox keeps or gets an empty string. The validator will not pass and the next button will keep you at the page until the file thing is solved. When the file upload is correct you can have a postback going to next step and rewind to the previous step and you still find your file in radasyncupload. Only at the last step where you assigned the button ID as the postbacktrigger of radasyncupload the data including the file will be available at code behind and can be processed.
Below is the javascript that I used. I create dynamic upload controls on a form depending if the user defined to have upload controls. The number of upload controls is less than 10 at max. Each control has its related textbox to check the upload status and test it with a related required field validator.
function OnClientValidationFailed(sender, args) {
// get the index number of the file upload object (if you have several on the same page the last character is the index number
var CurrentFileIndex = sender.get_id().slice(-1);
// reset the corresponding TB to an empty string to detect that is has not been uploaded
var textbox = $find('RegisterForm1_Step3_TB_REQUIRED_file' + CurrentFileIndex);
textbox.set_value('');
}
function OnClientFileUploaded(sender, args) {
var CurrentFileIndex = sender.get_id().slice(-1);
var textbox = $find('RegisterForm1_Step3_TB_REQUIRED_file'+CurrentFileIndex);
textbox.set_value(args.get_fileName());
}
function OnClientFileUploadRemoved(sender, args) {
var CurrentFileIndex = sender.get_id().slice(-1);
var textbox = $find('RegisterForm1_Step3_TB_REQUIRED_file' + CurrentFileIndex);
textbox.set_value('');
}