Uploadcontrol: RadUploadItem.SetError()

4 posts, 0 answers
  1. Neal Robben
    Neal Robben avatar
    5 posts
    Member since:
    Mar 2010

    Posted 29 Apr 2010 Link to this post

    In my code I use the method SetError() on a RadUploadItem in a validation routine, so the user can see an error icon displayed.

    Now I have to be able to clear the error again, from code.

    I have already tried to use SetError(""), and SetError(null). Neither of these seem to work.

    For now I have resorted to writing:

                        var temp = _RelatedUploadItem.ChildrenOfType<Grid>();

                        foreach (Grid grid in temp)
                            if (grid.Name == "IconError")
                                grid.Visibility = Visibility.Collapsed;

    I hope there is a cleaner way to do this, since this is really ugly code.
  2. Ivan
    Ivan avatar
    519 posts

    Posted 03 May 2010 Link to this post

    Hello Neal,

    Thank you for contacting us.

    Indeed the upload control is not prepared for such a detailed manipulation. Browsing the visual tree is the only available way till now (even there exists a method SetOK, it is internal one).

    However now we are implementing a set of new features (for example MVVM). According to the renovation of RadUpload, could you share with us the your scenario - we will try to cover it too.

    Looking forward for your reply.

    Best wishes,
    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. DevCraft R3 2016 release webinar banner
  4. Neal Robben
    Neal Robben avatar
    5 posts
    Member since:
    Mar 2010

    Posted 04 May 2010 Link to this post

    Hi Ivan,

    Thank you for the response and sorry it has taken me a while to reply, but I have been somewhat busy at work.

    The scenario for which we are using the RadUpload control is as follows:

    We basically want to upload a set of video-files (MPEG4, AVI,...) and for each file we also want to upload a meta-data file that contains information that the user entered about the video (Name, Description, Keywords,...). When both a video and it's meta-info file are uploaded, the server detects this and goes to work on them.

    So client-side, we have an upload-window in which a RadUpload control is used to select a set of video-files. After the files have been selected and are shown in the list, the user can see a new panel on the right of the window that contains textboxes, dropdowns, etc. for entering information about the videos.

    The user can switch between the selected videos and enter the information in the textboxes. Once the user is finished entering the information, he clicks the "Ok"-button. First the information about the videos is validate because certain fields (like "name") are mandatory. If this is left blank, then error-icons are shown on all of the RadUploadItems for which no corresponding name has been entered.

    If the validation succeeds, then the upload of the RadUpload control is triggered in code. Once this finished, meta-files are generated in memory and sent to the server, after which the window closes and we are done.

    We have been able to get the functionality we need so far, but for some of it the code is far from optimal (Like traveling the visual tree to find an element based on name just so we can make the error-icon invisible for example).

    First of all I think it would be a nice improvement if it were possible to cleanly get/set the currently selected RadUploadItem in the list of items, just like you can choose an element in a treeview or something for example. We currently just listen to a MouseClicked-event on one of the visual elements, and maintain some extra info in code to determine which RadUploadItem is the selected one.

    Another thing I found strange is: When you select a set of files, the system generates RadUploadItems for each of the files. But when you click "Add more files", the system re-generates all the RadUploadItems instead of just adding the new ones.
    We keep an object containing the information about the video (That was entered in the textbox) and save it as the "Tag"-property on the corresponding RadUploadItem. This object of ours is then set as the datacontext for the input controls (Textboxes for name, description etc.).

    We have written some code to keep the DataContext objects in list and when all the RadUploadItems are regenerated, we just set the objects as Tags on the newly generated RadUploadItems if these correspond to files that were selected before.

    Another thing that could be improved is the fact that I could only find the normal file-name in the new RadUploadItems that are created. There is no property that would give me the full path and name of the file. So when checking to see if a file has been added before I just do string comparisons on the Name and Size properties (Size just gives a string of the form "155 KB" if I am not mistaken. Maybe the exact filesize would also be nice)

    It would be nice to be able to clear an error (on a RadUploadItem) from code, after you have set it. (And for some reason the error-icon disappears when you click on it).

    It would also be very nice if there was a cleaner way to determine which of the buttons (Upload, Add more files, cancel, etc...) are shown. No we just followed the telerik documentation: searched for the visual elements and set the opacity and HitTestVisible properties.

    The templating system for the upload control is another point. Based on the telerik documentation we just had to make grids with names like "ErrorIcon" and "DeleteIcon" that contained or icons/buttons and let the RadUpload-control just search them by name.

    Also, I'm not sure if there is a clean way to just have a file in memory (Bytestream, byte array or something) and just upload it programmatically with the RadUpload control, so these files are stored server-side along the files that the user has uploaded by selecting them in RadUpload. For now we implement our own logic to write to the server-side .ashx page which also stores the video-files sent by RadUpload.

    I think that's about all I can say. I know it is a lot of text to read, but it would sure be appreciated if some of the points mentioned could be adressed in a future version of RadUpload.

    We are very happy with the way Telerik handles support by the way. You guys are very fast in replying and always have helpfull answers (and sample projects when needed).
  5. Ivan
    Ivan avatar
    519 posts

    Posted 09 May 2010 Link to this post

    Hello Neal Robben,

    Thank you the detailed information.

    Indeed all of your points are items in our to-do list. Below we will try to answer your questions.
    • Clear error element.
      Here you need to browse the visual tree and this way to hide the error icon. It will be helpful to preview the code of the SetOK method.
    • Full name of a file.
      It is a framework security limitation to have access only to the file name but not to the full name.
    • You can get the RadUploadItem using file-name:
      if (this.CurrentSession.FileNameUploadItem.ContainsKey(fileName))
          RadUploadItem item = this.CurrentSession.FileNameUploadItem[fileName];
          . . .
    • File Size:
      if (this.CurrentSession.ValidFiles.ContainsKey(fileName))
          RadUploadSelectedFile file = this.CurrentSession.ValidFiles[fileName];
          ... = file.Size;
    • Add more files functionality.
      In the current release we recreate all the RadUploadItems after new files append. Because of this you should disable this functionality after some of your specific information is entered.
    • About the control buttons.
      We will provide an interface to access these buttons. Probably this one will be available within the Q2 release.
    • Uploading a stream.
      You can supply a stream in FileUploadStarting event and this way to send a modified data. However this way the real file-content will be skipped.

    We hope this information will help you to accomplish your tasks.

    Kind regards,
    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.
Back to Top