3

I wonder how to reset (clear) RadAsyncUpload and leave the component as in the initial state

after the submission in the code behind?


my aspx ::

<telerik:RadAsyncUpload runat="server" ID="rada_attach" OnClientFileUploaded="onClientFileUploaded"
MultipleFileSelection="Disabled" InitialFileInputsCount="1" MaxFileInputsCount="1"
Width="100%" />
Community
  • 1
  • 1
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

2 Answers2

3

Try to add code below to Click event handler of submit button (not tested)

ScriptManager.RegisterStartupScript(this, this.GetType(), "clearUpload", String.Format("$find('{0}').deleteAllFileInputs()", rada_attach.ClientID), true);
Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68
  • `$find()` will return null in this case, as the control might not be ready on that state. Even `jQuery's $(document).ready()` will not help. Official support recommends to use a small timeout like `setTimeout(function () { $find('" + control.ClientID + "').deleteAllFileInputs(); }, 100);` to make sure, `$find()` will find the desired object. [Source](http://www.telerik.com/forums/find-doesn-t-work-when-called-through-scriptmanager-registerstartupscript) – Martin Braun Aug 15 '14 at 14:48
2

You want to clear the list of items after Upload? if yes,according to this link you can do like this :

<script type="text/javascript">
   function clientFileUploaded(sender, args) {
       var count = sender._getRowCount();

       if (count > 2) {
           Array.removeAt(sender._uploadedFiles, 0);
           sender.deleteFileInputAt(0);
           sender.updateClientState();
       }
   }

Arash
  • 3,013
  • 10
  • 52
  • 74