Cannot Cancel the OnClientMove

5 posts, 0 answers
  1. Brian
    Brian avatar
    68 posts
    Member since:
    Jun 2011

    Posted 27 Aug 2012 Link to this post

    I have reviewed several resources while trying to programmatically control whether a user should be allowed to rename an item in RadFileExplorer. Here are a couple of the resources that I have reviewed:

     

     

    The FileExplorer on my web page has a root folder. Under the root folder, I populate the explorer with “home folders”; this is done during the Page_Load event. You can think of the home folders like Windows Profiles. When a user logs into Windows, they have access to the folders that are associated with their profile. I am doing a similar thing with file explorer. When a user logs into my website, they have access to their home folder, its files, and its subdirectories. They do not have access to home folders that belong to other users and file explorer is configured so that it will not let a user see the home folders of other users.

     

    As you know, FileExplorer allows you to right-click on a file or folder, and click Rename. That is cool and it saves a lot of development time. In my web page, I allow users to rename anything they want. But I do not want them to be able to rename their home folder.

     

    My RadFileExplorer contains the following setting (among others): OnClientMove="fncMoveOrRename". My intent is to use this function that you see referenced here as a way to check whether the currently selected item in FileExplorer is a home folder vs. any other file or folder. If it’s a home folder, then cancel is set to true. But even when cancel is set to true, the rename still occurs. Is the documentation that I referenced above correct? I should be able to prevent a rename by canceling the OnClientMove, right?

     

    To determine if the problem had anything to do with my logic, I stripped everything out of fncMoveOrRename, and I am left with the following:

     

    function fncMoveOrRename(objExplorer, eventArgs) {

        alert("Click OK to cancel.");

        eventArgs.set_cancel(true);

    }

    When I rename a folder, the alert message appears, and I click OK. But cancel is never triggered. I still have the undesirable effect of having the folder renamed even though cancel is set to true. What am I missing here?

     

    Thank you,

    Steven

  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 30 Aug 2012 Link to this post

    Hi Steven,

    I am not quite sure what is causing the described behavior for you. The ClientMove client-side event is the one that you need to handle to achieve the required result. I tried the provided event handler and the event is correctly canceled on my side. Could you please provide more detailed information regarding the specific scenario?
    • Which version of RadControls for ASP.NET AJAX and .NET Framework are used in the application?
    • Under which browser and its version the problem occurs?
    • Are you able to reproduce the problem on the live demos? If so, could you please provide the exact steps the need to be executed in order to reproduce the issue?
    • Could you please provide a simple fully runnable project reproducing the problem so we can investigate it further?

    For your convenience I have attached my test page, could you please modify it to a point where the problem occurs and send it back?


    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian
    Brian avatar
    68 posts
    Member since:
    Jun 2011

    Posted 30 Aug 2012 Link to this post

    Hello Dobromir,
    Thank you for replying to my issue and for including the test files.

    I have downloaded your test files, but before I could use them, I had to rename your test files. Your test page is Default.aspx and my project already has a Default.aspx page. So I renamed your test files as follows:

        Default.aspx       FERenameTest.aspx

        Default.aspx.cs    FERenameTest.aspx.cs

    I then used Notepad to make the following changes to files FERenameTest.aspx and FERenameTest.aspx.cs. Inside of file FERenameTest.aspx, I changed:

        CodeFile="Default.aspx.cs"
    to:
        CodeFile="FERenameTest.aspx.cs"

    I also changed:

        Inherits="_Default"
    to:
        Inherits="FERenameTest"

    And inside of file FERenameTest.aspx.cs, I changed:

        public partial class _Default
    to:
        public partial class FERenameTest

    After making the above modifications with Notepad, I then added files FERenameTest.aspx and FERenameTest.aspx.cs to my existing Visual Studio project.

    After recompiling my Visual Studio project, I went to Solution Explorer, right-clicked on FERenameTest.aspx, and clicked Open. After FERenameTest.aspx was opened, I went to the Debug menu, and clicked on Start Debugging. This opened FERenameTest.aspx in a localhost instance and displayed FileExplorer with a single folder called ROOT. Of course, you cannot rename a root folder, so I right-clicked on the ROOT folder, and clicked New Folder. This displayed a radwindow with a default new folder name of NewFolder. I kept the default folder name by simply clicking [OK], and a new subfolder appeared under ROOT called NewFolder.

    I then right-clicked on NewFolder and clicked on Rename. I typed in OldFolder and pressed Enter. Pressing the Enter key caused the alert message (within fncMoveOrRename) to appear. When I clicked [OK] on the message, the folder is now named OldFolder, instead of retaining the original name of NewFolder.

    I then created a brand new Telerik Web (C# RadControls Web Site) project, which automatically included the page Default.aspx. I deleted the Default.aspx page that was included in the new project and added the original test files that you provided. I then repeated the Rename steps, as outlined above, but I got the same results. When I right-clicked on NewFolder within the new project and clicked Rename, I typed in OldFolder and pressed Enter, and the alert message appeared. I clicked [OK] on the alert, but the folder is now named OldFolder, instead of retaining the original name of NewFolder.

    I cannot reproduce this problem using the Telerik demo. For example, this demo currently has a subfolder called Hello world. If I try to rename this folder to Hello Earth, I get an access denied alert, and when I click [OK] on the alert, Hello Earth is rolled back to Hello world.

    So this doesn’t appear to be a problem with my web browser or its version. It sounds like there is something not right within my development environment. Here is my environment:

        Windows 7

        Internet Explorer 9

        Visual Studio 2010

        Projects based on .NET Framework 4.0

        RadControls v.2012.2.607.40 (Dev)

    I appreciate any help that you can provide.
    Thank you,

    Steven

  5. Vessy
    Admin
    Vessy avatar
    1382 posts

    Posted 03 Sep 2012 Link to this post

    Hi Steven,

    I was able to reproduce the issue. We will look into it and will try to fix it in due time. You can track the progress through its PITS item: Public URL.

    Nevertheless, during the testing we found that the issue appears only when the folder is being renamed through the TreeView (not through the GridView on the left). As a workaround I could suggest you to remove the "Rename" option from the TreeView's context menu - you could find more information on how to achieve this in the following KB article: Remove the "Delete" and "Upload" commands from the RadFileExplorer control.

    As a small token of our gratitude for your efforts I have updated your Telerik points.

    Regards,
    Veselina
    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. Brian
    Brian avatar
    68 posts
    Member since:
    Jun 2011

    Posted 04 Sep 2012 Link to this post

    Hi Veselina
    Thank you for your feedback.

    Not sure why you only repro the problem in the treeview and not the gridview. In my case, the problem occurs in both treeview and the grid. Maybe your version of the RadControls are different from mine.

    So since I have the problem in both treeview and gridview, I have removed the Rename option from both shortcuts. I had to also set the EnableDragAndDrop property to false, since it is managed by the same OnClientMove event. There are times when I will need to be able to cancel drag/drops as well.

    This was a feature that we were expecting to have with the FileExplorer and now it is not available for our end-users. I would like to be able to turn this feature back on as soon as possible, so I will continue to monitor this issue through PITS.

    Thank you,
    Steven
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017