Problem with quotes in folder name

8 posts, 0 answers
  1. Roman
    Roman avatar
    25 posts
    Member since:
    Sep 2010

    Posted 12 Mar 2012 Link to this post

    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.
  2. Roman
    Roman avatar
    25 posts
    Member since:
    Sep 2010

    Posted 13 Mar 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roman
    Roman avatar
    25 posts
    Member since:
    Sep 2010

    Posted 14 Mar 2012 Link to this post

    Can you also help me how to set maxlength in creating new folder or renaming file/folder.
    Thanks
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 15 Mar 2012 Link to this post

    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.
  6. Roman
    Roman avatar
    25 posts
    Member since:
    Sep 2010

    Posted 21 Mar 2012 Link to this post

    Thanks for help.
    Can i avoid typing more then for example 20 symbols?
    Just like setting maxlength for input.

    Thanks.
  7. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 26 Mar 2012 Link to this post

    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.
  8. Roman
    Roman avatar
    25 posts
    Member since:
    Sep 2010

    Posted 28 Mar 2012 Link to this post

    Hi Dobromir.
    Thanks for help.
    What if we have several localizations ?
  9. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 30 Mar 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017