I have two RadAsyncUpload control first one upload Multiple Files and the second one upload one file.
the second one has custom validator that validate the user upload file .
the first one fire ajax when the files uploaded .
but the second one doesn’t fire any ajax because the user should click upload button.
The problem is when the custom validator is fire the error msg the first one doesn’t fire the ajax but when I fire it twice it will make postback .
Here is the two controls:
<telerik:RadAsyncUpload ID="tlkasycupMultipleFile" runat="server" MultipleFileSelection="Automatic"
MaxFileInputsCount="100" OnFileUploaded="fnOnFileUploaded" OnClientFilesUploaded="fileUploaded"
OnClientFileUploadFailed="OnClientFileUploadFailed" OnClientFilesSelected="fnShowProgressArea"
OnClientValidationFailed="fnOnValidationFailedFileUpload" >
</telerik:RadAsyncUpload>
<table>
<tr>
<td>
<telerik:RadTextBox ID="radtxtUploadName" runat="server" Label="Upload Name " LabelWidth="100px"
meta:resourcekey="radtxtUploadNameResource1" Width="260px" ClientEvents-OnValueChanging="fnUploadNameTextChanged">
</telerik:RadTextBox>
<br />
<asp:CustomValidator ID="wcvIsSingleFileUploadNameExist" runat="server" Display="Dynamic"
ValidationGroup="UploadSingleFile" SetFocusOnError="true" ClientValidationFunction="fnIsSingleFileUploadNameExist"
ControlToValidate="radtxtUploadName" ErrorMessage="An Uploaded File with this name already exists. Please enter a different name"
Font-Bold="true"></asp:CustomValidator>
</td>
</tr>
<tr>
<td>
<telerik:RadTextBox ID="radtxtDescription" runat="server" Label="Description" LabelWidth="64px"
meta:resourcekey="radtxtDescriptionResource1" Width="260px">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td>
<telerik:RadAsyncUpload ID="tlkasycupSingleFileUpload" runat="server" MultipleFileSelection="Disabled"
MaxFileInputsCount="1" OnClientFilesUploaded="fnHideProgreesArea" OnClientFileUploadFailed="OnClientFileUploadFailed"
OnClientFilesSelected="fnShowProgressAreaAndDisableValidator" OnClientValidationFailed="fnOnValidationFailedFileUpload">
</telerik:RadAsyncUpload>
<asp:CustomValidator ID="wcvValidUploadFile" runat="server" Display="Dynamic" ValidationGroup="UploadSingleFile"
SetFocusOnError="false" ClientValidationFunction="fnCheckUploadFile" ErrorMessage="Please select file to upload it."
Font-Bold="true"></asp:CustomValidator>
</td>
</tr>
<tr>
<td>
<telerik:RadButton ID="rbtnUploadSingleFile" runat="server" Text="Upload" OnClick="rbtnUploadSingleFile_Click"
ValidationGroup="UploadSingleFile" OnClientClicking="fnEnableCustomeValidator">
</telerik:RadButton>
</td>
</tr>
</table>
Here is the javascript :
// to fire Ajax Manager to make postback
function fileUploaded(sender, args) {
// ValidatorEnable(document.getElementById('< %=wcvValidUploadFile.ClientID%>'),false);
// ValidatorEnable(document.getElementById('< %=wcvIsSingleFileUploadNameExist.ClientID%>'),false);
var radAjaxManager = <%=RadAjaxManagerFileUpload.ClientID%>;
$('[id$=tlkrprogarFileUpload]').hide();//to hide Progress Erea after client complete uploading
radAjaxManager.ajaxRequest();//to fire ajax to make postback
}
//function to Enable custom Validator with single upload name
function fnEnableCustomeValidator(sender,eventArgs){
ValidatorEnable(document.getElementById('<%=wcvValidUploadFile.ClientID%>'),true);
if (Page_ClientValidate('UploadSingleFile')==false) {
eventArgs.set_cancel(true);
}
}
//check if single file upload is selected or not
function fnCheckUploadFile(sender, args) {
var check = true;
var UploadedFile = $find("<%= tlkasycupSingleFileUpload.ClientID %>").getUploadedFiles();
var count=UploadedFile.length;
if(count==0){
check=false
}
args.IsValid = check;
}
Here is the snapshots : look at the attachment
And here is the ajax manger :
<telerik:RadAjaxManager ID="RadAjaxManagerFileUpload" runat="server" EnablePageHeadUpdate="False">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManagerFileUpload">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radgSupAcctFileUploads" />
<telerik:AjaxUpdatedControl ControlID="tlkasycupMultipleFile" />
<telerik:AjaxUpdatedControl ControlID="tlkRadWindowManager" />
<telerik:AjaxUpdatedControl ControlID="tlkasycupSingleFileUpload" />
<telerik:AjaxUpdatedControl ControlID="radtxtUploadName" />
<telerik:AjaxUpdatedControl ControlID="radtxtDescription" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="radgSupAcctFileUploads">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radgSupAcctFileUploads" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="rbtnUploadSingleFile">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="radgSupAcctFileUploads" />
<telerik:AjaxUpdatedControl ControlID="tlkasycupSingleFileUpload" />
<telerik:AjaxUpdatedControl ControlID="tlkRadWindowManager" />
<telerik:AjaxUpdatedControl ControlID="radtxtUploadName" />
<telerik:AjaxUpdatedControl ControlID="radtxtDescription" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
Kindly help me .