Disable Upload Button

6 posts, 0 answers
  1. Jim
    Jim avatar
    42 posts
    Member since:
    Mar 2009

    Posted 16 Apr 2010 Link to this post

    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?
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 20 Apr 2010 Link to this post

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

    Posted 16 Aug 2010 Link to this post

    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.
  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 18 Aug 2010 Link to this post

    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
  6. Divyesh
    Divyesh avatar
    13 posts
    Member since:
    Sep 2008

    Posted 18 Apr 2011 Link to this post

    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
  7. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 18 Apr 2011 Link to this post

    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.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017