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

Remove Link

5 Answers 159 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
mosswgreentea
Top achievements
Rank 1
mosswgreentea asked on 22 Jun 2010, 05:56 PM
I have a requirement that if the validation of the file selected fails and the onclientvalidationfailed method fires, I want to be able to give a generic error message and then automatically Remove the file.

How do I achieve this? I am able to get handle on the 'Remove' button and use remove.click(). But it does nothing. Am I missing something?

5 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 25 Jun 2010, 10:40 AM
Hi Arvind Ganapathy,

You can use the following sample code to achieve this:

<form id="form1" runat="server">
  <asp:ScriptManager runat="server" ID="ScriptManager1">
  </asp:ScriptManager>
  <script type="text/javascript">
      function clientValidation(sender, args) {
           
      }
 
      function validationFailed(sender, args) {
          var $ = $telerik.$;
          var row = $(args.get_fileInputField()).parents("li")[0];
          var index = $(row).index();
          alert('validation failed');
 
          sender.deleteFileInputAt(index);
      }
       
  </script>
   
  <div>
      <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1"
          OnClientValidationFailed="validationFailed"
          AllowedFileExtensions=".jpeg,.jpg">
      </telerik:RadAsyncUpload>
   
      <asp:Button runat="server"  ID="Button1" Text="Text1" />
  </div>
  </form>

The event will kick off if file with extension different from .jpeg,.jpg is uploaded.

Best wishes,
Genady Sergeev
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
Lenny_shp
Top achievements
Rank 2
answered on 21 Jul 2010, 09:48 PM
2010.2.720.35

Object doesn't support this property or method.

 var row = $(args.get_fileInputField()).parents("li")[0];
0
Peter
Telerik team
answered on 27 Jul 2010, 12:18 PM
Hello Lenny_shp,

Indeed, the 2010.2.720 version does not have the get_fileInputField() for the eventArgs of the OnClientValidationFailed event. I have logged the issue and updated your Telerik points.


All the best,
Peter
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
support
Top achievements
Rank 1
answered on 30 Dec 2010, 04:31 AM
So what is the workaround or substitute method to use in this case?
0
Genady Sergeev
Telerik team
answered on 04 Jan 2011, 01:24 PM
Hello,

Forth from Q3 2010 you can obtain the file input, if available (it is available only if the IFrame module is being used) using the following code:

<script type="text/javascript">
        function failed(sender, args) {
            var textInput = $telerik.$("input[type='text']", args.get_row())[0];
        }
     
    </script>
     
    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" OnClientValidationFailed="failed"
        AllowedFileExtensions="gif">
    </telerik:RadAsyncUpload>

If you need to obtain the name of the file that has failed validation you can use the

var fileName = args.get_fileName()

property.

Greetings,
Genady Sergeev
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
AsyncUpload
Asked by
mosswgreentea
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Lenny_shp
Top achievements
Rank 2
Peter
Telerik team
support
Top achievements
Rank 1
Share this question
or