Is the UploadServiceUrl required?

2 posts, 0 answers
  1. DogEars
    DogEars avatar
    79 posts
    Member since:
    Jun 2007

    Posted 28 Sep 2011 Link to this post

    I'm trying to construct a stand-alone web resource for CRM and I'm wondering if I have to provide an upload handler to the control?

    I had planned to just do something like this using the SharePoint Client Object Model from the FileUploading event in my xaml code behind:

    public void UploadDocument(string siteURL, string documentListName, string documentListURL, string documentName, byte[] documentStream)
               using (ClientContext clientContext = new ClientContext(siteURL))
                   //Get Document List
                   List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);
                   var fileCreationInformation = new FileCreationInformation();
                   //Assign to content byte[] i.e. documentStream
                   fileCreationInformation.Content = documentStream;
                   //Allow owerwrite of document
                   fileCreationInformation.Overwrite = true;
                   //Upload URL
                   fileCreationInformation.Url = siteURL + documentListURL + documentName;
                   Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);
                   //Update the metadata for a field having name "DocType"
                   //uploadFile.ListItemAllFields["DocType"] = "Favourites";

    So is this possible or does the control need to offload to a handler to perform this type of action?

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 03 Oct 2011 Link to this post

    Hi Dogears,

    The RadUpload control basically has two sides - the client side UI and the server-side handler. And when you hit the Upload button of the control, it will send a request to the server and if there isn't an RadUploadHandler that can handle the upload, an exception will be raised and the control will display it.

    You can implement your scenario and cancel the upload using the RadUpload.CancelUpload() method but again the RadUpload will be in the appropriate visual state - canceled upload. This is why I believe it would be better to create a custom upload control. For example you can create a ListBox to display the list of selected items that you can select through the OpenFileDialog.

    However, if you want to use the RadUpload control to upload files to a SharePoint sever,you can follow this tutorial I also attached a sample project where the approach described in the video tutorial is used. Please, note that the UploadHandler implementation in the attached solution is different from the one demonstrated in the video tutorial. This is due to the improvements in the RadUpload control and it is best to use the UploadHandler implementation from the attached solution.

    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top