I have a button that uploads the selected file through RadInput. However, if the user clicks it and the selected file input is blank it errors. How can I check whether the RadInput is blank or null so I can send a custom error. Or can I hook it up to a validator?
You have entered an invalid file. The file extension must be either XLS or XLSX! Please select another file!
</asp:CustomValidator>
Then JavaScript
<scripttype="text/javascript">
function validateRadUploadNoBlanks(source, e) {
e.IsValid = false;
var upload = $find("<%= RadUpload1.ClientID %>");
var inputs = upload.getFileInputs();
for (var i = 0; i < inputs.length; i++) {
//check for empty string or invalid extension
if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) {
e.IsValid= true;
break;
}
}
}
</script>
Then code behind on custom validator
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
'add this to the custom validator along with the java script function validateRadUploadNoBlanks