This is a migrated thread and some comments may be shown as answers.

RadUpload and ReadOnlyFileInputs property set to false

3 Answers 90 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Mark DeMichele
Top achievements
Rank 1
Mark DeMichele asked on 13 Jul 2009, 07:30 PM
Hi there,

I see a lot of posts in this forum about the ReadOnlyFileInputs property set to true, but I'm actually looking for the opposite.

The problem is that the behavior seems to be inconsistent across browsers.

In FF3, the field is not editable at all, and even if the property is set to false, clicking inside the text box results in a file selection dialog.

In IE7, the field is editable, but if an invalid name is typed in manually, either a Javascript error occurs or the UploadedFiles property indicates that a 0 byte file with the invalid name was uploaded upon submission of the form.

Any way to get around the inconsistencies besides setting the ReadOnlyFileInputs property to false?

Thanks,
Mark

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 14 Jul 2009, 01:40 PM
Hi Mark DeMichele,

You can disable the entering of text in the file input using the following  JavaScript code:

 
 function pageLoad() { 
            var $ = $telerik.$; 
            var upload = $find("RadUpload1"); 
            $(".ruFileInput", upload.get_element()).bind("keypress"function(e) { 
                e.preventDefault(); 
                return false
            }); 
        } 

However, it is impossible to open the file dialog using JavaScript, this prohibition is due to a security reasons, and it is impossible to work around it.



All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mark DeMichele
Top achievements
Rank 1
answered on 14 Jul 2009, 02:31 PM
Hi Genady,

Actually, I did want to leave ReadOnlyFileInputs to false so that the box would be editable, specifically after a file is chosen. The problem is that the behavior with this property set to false is the inconsistency between browsers. I'm just curious whether there is any way to get around it short of disabling the edit functionality altogether.

Sorry for the confusion.

Thanks,
Mark
0
Genady Sergeev
Telerik team
answered on 14 Jul 2009, 04:10 PM
Hi Mark DeMichele,

Unfortunately there is no way to force text entering in FireFox. The file input there is designed in a way, that a click on the text box opens file dialog. This behavior cannot be changed. What is worse, in safari there is no text box at all, so the text entering is not an option too. IE8 no longer allows for text entering in the input file as well. So the only option to obtain consistent behavior is to disable the text entering. Here is updated version of the fore mentioned code, that will work under all common browsers:

 
<script type="text/javascript"
        function pageLoad() {  
            var $ = $telerik.$;  
            var upload = $find("RadUpload1");  
            $(".ruFileInput, .ruFakeInput", upload.get_element()).bind("keypress"function(e) {  
                e.preventDefault();  
                return false;  
            });  
        }  
     
    </script> 


Regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Upload (Obsolete)
Asked by
Mark DeMichele
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Mark DeMichele
Top achievements
Rank 1
Share this question
or