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

Disable Upload Button

5 Answers 310 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 16 Apr 2010, 11:24 PM
How would you go about disabling the upload button on the popup window after it is clicked for the first time. I don't want to allow users to hit it twice.

Can you add a progress bar while uploading is going on?

5 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 20 Apr 2010, 12:24 PM
Hi Jim,

By design, RadFileExplorer does not offer the possibility to disable the Upload button. However, you can attach a handler  to the click event on the button and disable it using the following approach:

function OnClientLoad(explorer, args)
{
    var windowManager = explorer.get_windowManager();
 
    windowManager.add_show(function(sender, args)
    {
        var isClicked = false;
 
        //make sure the sender is upload dialog
        if (sender.get_name() == "fileExplorerUpload")
        {
            //get reference to the upload button *note the ID*
            var btnUpload = document.getElementById("RadFileExplorer1_btnUpload");
 
            if ($telerik.isIE)
            {
                btnUpload.attachEvent("onclick", function(e)
                {
                    //disable the input element
                    e.srcElement.disabled = "disabled";
                });
            }
            else
            {
                btnUpload.addEventListener("click", function(e)
                {
                    //disable the input element
                    e.currentTarget.disabled = "disabled";
                }, false);
            }
        }
    });
     
}

Regarding your second question, please check the following KB article:
Add a RadProgressArea inside the Upload dialog


Regards,
Dobromir
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Thomas
Top achievements
Rank 1
answered on 16 Aug 2010, 05:24 AM
You answer is exactly what I was looking for, except that I am not sure how to use the code snippet.  I added it to my code, but the function "OnClientLoad" is not getting called automatically.  And when I forced to call the function "OnClientLoad", it throws an javascript error saying that explorer.get_windowManager(); returns null.
0
Fiko
Telerik team
answered on 18 Aug 2010, 04:08 PM
Hi Thomas,

In your case I recommend you to use this approach, because it will disable the upload command for the entire RadFileExplorer controls (including ContextMenus):
  • Implement the PageLoad event to looks like this:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string path = this.ResolveUrl("~/ROOT");
            RadFileExplorer1.Configuration.ViewPaths = new string[] { path };
            RadFileExplorer1.Configuration.UploadPaths = new string[] { path };
            RadFileExplorer1.Configuration.DeletePaths = new string[] { path };
        }
        else
        {
            if (RadFileExplorer1.Upload.UploadedFiles.Count > 0)
            {// A postback with uploaded files ==> uploading file(s)
                RemoveUploadCommand(RadFileExplorer1);
            }
        }
    }
  • Implement the RemoveUploadCommand method based on this KB article:

    private void RemoveUploadCommand(RadFileExplorer fileExplorer)
    {
        int i;// Global variable for that function
     
        RadToolBar toolBar = fileExplorer.ToolBar;
        // Remove commands from the ToolBar control;
        i = 0;
        while (i < toolBar.Items.Count)
        {
            if (toolBar.Items[i].Value == "Upload")
            {
                toolBar.Items.RemoveAt(i);
                continue; // Next item
            }
     
            i++;// Next item
        }
     
        RadContextMenu treeViewContextMenu = fileExplorer.TreeView.ContextMenus[0];
        // Remove commands from the TreeView's ContextMenus control;
        i = 0;
        while (i < treeViewContextMenu.Items.Count)
        {
            if (treeViewContextMenu.Items[i].Value == "Upload")
            {
                treeViewContextMenu.Items.RemoveAt(i);
                continue;// Next item
            }
     
            i++;// Next item
        }
     
        RadContextMenu gridContextMenu = fileExplorer.GridContextMenu;
        // Remove commands from the GridContextMenu control;
     
        i = 0;
        while (i < gridContextMenu.Items.Count)
        {
            if (gridContextMenu.Items[i].Value == "Upload")
            {
                gridContextMenu.Items.RemoveAt(i);
                continue;// Next item
            }
     
            i++;// Next item
        }
    }
I hope this helps.

Kind regards,
Fiko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Divyesh
Top achievements
Rank 1
answered on 18 Apr 2011, 12:46 PM
Hi there,

I implemented the code first suggested code but in IE the upload function doesnt upload the file. It disables the button but does not upload the file any suggestion please.

Regards
Divyesh
0
Dobromir
Telerik team
answered on 18 Apr 2011, 02:53 PM
Hi Divyesh,

I tested the code and it is working as expected. Could you please provide more detailed information on the specific scenario? Under which version of Internet Explorer you experience this problem?

For your convenience I have attached a sample page with the approach implemented. Could you please modify it to a point where the problem occurs and send it back so we can investigate the issue further? Also I have prepared a video demonstrating my test, could you please see if I am doing something wrong?
http://screencast.com/t/6KidqRSlka

Greetings,
Dobromir
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
FileExplorer
Asked by
Jim
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Thomas
Top achievements
Rank 1
Fiko
Telerik team
Divyesh
Top achievements
Rank 1
Share this question
or