I think I'm doing something wrong here. I have a RadAsyncUpload control and a submit button on the page to cause the postback. All I want to do is prevent the postback if no file has been selected, or have the submit button disabled until a file is selected. If it makes any difference this is all inside of a RadWindow.
Here's the markup for the RadAsyncUpload
<
div
class
=
"formRow"
id
=
"divAttachFile"
runat
=
"server"
style
=
"height: 60px;"
>
<
div
class
=
"floatLeft"
>
<
label
for
=
"asyncFlUpldAttachment"
><
span
id
=
"spnUploadFileMark"
runat
=
"server"
class
=
"validator"
>*</
span
> Upload File: </
label
>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
MaxFileSize='<%$ AppSettings:MAXATTCHFILESIZE %>'
MultipleFileSelection="Disabled" MaxFileInputsCount="1" AllowedFileExtensions='<%$ AppSettings:ATTCHFILEEXTNS %>'
EnableInlineProgress="true" TemporaryFileExpiration="36000"
OnClientValidationFailed="validationFailed"
OnClientFileUploading="fileUploading"
OnClientFileUploadFailed="fileUploadFailed"
PostbackTriggers="lnkBtnAttachmentCancel"
TabIndex="100">
</
telerik:RadAsyncUpload
>
<
span
id
=
"ErrorHolder"
style
=
"display: none"
class
=
"validator"
></
span
>
</
div
>
</
div
>
Here's the current JavaSrcipts, pretty much straight from your samples
<script type=
"text/javascript"
>
var
pageIsValid =
true
;
function
validationFailed(sender, args) {
$(
"#ErrorHolder"
).show();
var
fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf(
'.'
) + 1, args.get_fileName().length);
if
(args.get_fileName().lastIndexOf(
'.'
) != -1) {
//this checks if the extension is correct
if
(sender.get_allowedFileExtensions().indexOf(fileExtention) == -1) {
$(
"#ErrorHolder"
).html(
"Wrong Extension! Verify file."
);
}
else
{
$(
"#ErrorHolder"
).html(
"The file size exceeds the limit"
);
}
}
else
{
$(
"#ErrorHolder"
).html(
"Wrong Extension! Verify file"
);
}
sender.deleteFileInputAt(0);
}
function
fileUploading(sender, args) {
$(
"#ErrorHolder"
).hide();
}
function
fileUploadFailed(sender, args) {
$(
"#ErrorHolder"
).show();
$(
"#ErrorHolder"
).html(
"File upload failed for:"
+ args.get_fileName());
sender.deleteFileInputAt(0);
}
</script>
Thanks
Rodney