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

Problem with quotes in folder name

7 Answers 88 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Roman
Top achievements
Rank 1
Roman asked on 12 Mar 2012, 04:05 PM
I use Custom provider. 

Step to reproduce:
Create folder with name like: !@#$%^&&&^*()_+~|":}{?><,./;'[]\=-0987654321`

after clicking on that folder i get an error: 
Callback Loading error: ...Should be like in demo: invalid

should be like in demo: alert with text.

7 Answers, 1 is accepted

Sort by
0
Roman
Top achievements
Rank 1
answered on 13 Mar 2012, 11:24 AM
The same problem with renaming files.
When i try to rename file with symbol "/" for example "aaa/aaa" fileexplorer gets an error path permission.
I guess it because that i try to create file in another directory (root/upload/aaa), but we have permission to upload files only into root/upload.
How can i validate file name before sending to (server)provider? 

Thanks
0
Roman
Top achievements
Rank 1
answered on 14 Mar 2012, 11:01 AM
Can you also help me how to set maxlength in creating new folder or renaming file/folder.
Thanks
0
Pero
Telerik team
answered on 15 Mar 2012, 01:18 PM
Hello Roman,

To validate the name of the newly created folder I would suggest handling the "createNewFolder" client-side event (OnClientCreateNewFolder property) and checking the name. The args.get_newPath() method will return you the new name of the folder.
function OnCreateFolder(sender, args)
{
    alert("Folder name: " + args.get_newPath());
}

Renaming a file or folder is actually moving the same file or folder, so that's why you should handle the "move" client-side event to validate the file name. To distinguish between move and rename you should handle the "rowDropping" event of the grid, and "nodeDropping" of the treeview.

For your convenience I have created a sample project demonstrating this approach for validation. I hope it helps.


Regards,
Pero
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Roman
Top achievements
Rank 1
answered on 21 Mar 2012, 04:40 PM
Thanks for help.
Can i avoid typing more then for example 20 symbols?
Just like setting maxlength for input.

Thanks.
0
Dobromir
Telerik team
answered on 26 Mar 2012, 08:38 AM
Hi Roman,

You can achieve the required functionality using the following JavaScript.
<telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientLoad="explorerLoad">
    <Configuration ViewPaths="~/ROOT" UploadPaths="~/ROOT" DeletePaths="~/ROOT" />
</telerik:RadFileExplorer>
 
<script type="text/javascript">
    function explorerLoad(explorer)
    {
        //assign handler to the window manager's show handler
        explorer.get_windowManager().add_show(showHandler);
    }
 
    function showHandler(wnd, args)
    {
        if (wnd.get_title() == "Rename")//check if the opened window is the Rename dialog
            $telerik.$(".rwDialogInput", wnd.get_contentElement()).bind("keydown", function (e)//handle inputs keydown event
            {
                //check if the text in the input is less than 20 symbols and if enter, esc, backspace, delete keys pressed
                if (e.target.value.length >= 20 && e.keyCode != 13 && e.keyCode != 27 && e.keyCode != 8 && e.keyCode != 46)
                    $telerik.cancelRawEvent(e);//cancel the key press event
            });
    }
</script>

An alternative solution to this case would be to customize the prompts template of the RadWindowManager used in the explorer. You can find how to achieve this in the following KB article:
Change the templates of the predefined dialogs (radalert, radconfirm and radprompt)

Kind regards,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Roman
Top achievements
Rank 1
answered on 28 Mar 2012, 12:41 PM
Hi Dobromir.
Thanks for help.
What if we have several localizations ?
0
Dobromir
Telerik team
answered on 30 Mar 2012, 11:04 AM
Hi Roman,

You can get the localized value of the "Rename" string using the explorer's get_localization() client-side meethod, e.g.:
function showHandler(wnd, args)
{
    var explorer = $find("<%=RadFileExplorer.ClientID%>");//get reference to the explorer's client-side object
    if (wnd.get_title() == explorer.get_localization()["Rename"])//check if the opened window is the Rename dialog
        ........
}


Greetings,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
FileExplorer
Asked by
Roman
Top achievements
Rank 1
Answers by
Roman
Top achievements
Rank 1
Pero
Telerik team
Dobromir
Telerik team
Share this question
or