Here is the scenario. There is a raddropdownlist and an asyncupload. The user should select an item (file type) from the drop down and this is a required field. I want to validate this field whenever the user attempt to upload a file. That is if the user didn't choose any file type and attempt to click the Select button, asyncupload should not open the File Select dialog. Instead it should validate the raddropdownlist which is the required field.
4 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 29 Oct 2013, 04:43 AM
Hi Merin,
Please have a look into the following code I tried which works fine at my end.
ASPX:
JavaScript:
Thanks,
Shinu.
Please have a look into the following code I tried which works fine at my end.
ASPX:
<
telerik:RadDropDownList
ID
=
"RadDropDownList1"
runat
=
"server"
DefaultMessage
=
"Select File Type"
>
<
Items
>
<
telerik:DropDownListItem
runat
=
"server"
Text
=
"JPG"
/>
<
telerik:DropDownListItem
runat
=
"server"
Text
=
"DOC"
/>
<
telerik:DropDownListItem
runat
=
"server"
Text
=
"PDF"
/>
</
Items
>
</
telerik:RadDropDownList
>
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ControlToValidate
=
"RadDropDownList1"
ForeColor
=
"Red"
ErrorMessage
=
"*"
></
asp:RequiredFieldValidator
>
<
br
/>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
MultipleFileSelection
=
"Automatic"
/>
JavaScript:
<script type=
"text/javascript"
>
function
pageLoad() {
var
$ = $telerik.$;
$(
".ruFileInput"
).click(
function
myfunction(e) {
if
(!Page_ClientValidate()) {
e.stopPropagation();
e.preventDefault();
}
});
}
</script>
Thanks,
Shinu.
0
Merin
Top achievements
Rank 1
answered on 01 Nov 2013, 08:37 AM
Hi Shinu,
Noticed an issue now. The code is working properly in my local machine but the exact code does not work in IE9 in Windows server 2008. I didn't made any change but the validation is not firing and the dialog is opening to select the files. Any configuration needed in the server?
Noticed an issue now. The code is working properly in my local machine but the exact code does not work in IE9 in Windows server 2008. I didn't made any change but the validation is not firing and the dialog is opening to select the files. Any configuration needed in the server?
0
Shinu
Top achievements
Rank 2
answered on 01 Nov 2013, 10:29 AM
Hi Merin,
You don't need any configuration settings in the server as this issue is related to the upload module being used in the respective browser. Please have in mind that such validation can not be achieved when RadAsyncUpload uses Silverlight upload module. In IE-9, the default upload module used is Silverlight and that is why the validation is not working. In your local machine you may be using a later version of IE such as IE-10 which uses FileApi and this works.
You can use the following client side code to disable Silverlight module.
JavaScript:
Thanks,
Shinu.
You don't need any configuration settings in the server as this issue is related to the upload module being used in the respective browser. Please have in mind that such validation can not be achieved when RadAsyncUpload uses Silverlight upload module. In IE-9, the default upload module used is Silverlight and that is why the validation is not working. In your local machine you may be using a later version of IE such as IE-10 which uses FileApi and this works.
You can use the following client side code to disable Silverlight module.
JavaScript:
<script type=
"text/javascript"
>
Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable =
function
() {
return
false
; }
function
pageLoad() {
var
$ = $telerik.$;
$(
".ruFileInput"
).click(
function
myfunction(e) {
if
(!Page_ClientValidate()) {
e.stopPropagation();
e.preventDefault();
}
});
}
</script>
Thanks,
Shinu.
0
Merin
Top achievements
Rank 1
answered on 03 Nov 2013, 02:55 PM
Hi Shinu,
Thank you for the quick valuable support and now the issue is resolved. You guessed it correctly, my local machine is running IE10. :)
Regards,
Merin
Thank you for the quick valuable support and now the issue is resolved. You guessed it correctly, my local machine is running IE10. :)
Regards,
Merin