Remove Link

6 posts, 0 answers
  1. mosswgreentea
    mosswgreentea avatar
    10 posts
    Member since:
    Dec 2009

    Posted 22 Jun 2010 Link to this post

    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?
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 25 Jun 2010 Link to this post

    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
  3. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 21 Jul 2010 Link to this post

    2010.2.720.35

    Object doesn't support this property or method.

     var row = $(args.get_fileInputField()).parents("li")[0];
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 27 Jul 2010 Link to this post

    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
  5. support
    support avatar
    10 posts
    Member since:
    Aug 2010

    Posted 29 Dec 2010 Link to this post

    So what is the workaround or substitute method to use in this case?
  6. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 04 Jan 2011 Link to this post

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