Multiple RadAsync controls w/Javascript

1 posts, 0 answers
  1. Angie
    Angie avatar
    113 posts
    Member since:
    Jan 2008

    Posted 11 Apr 2018 Link to this post

    Hello.  I've placed a RadAsyncUpload control in a user control and loaded that user control multiple times on a parent user control.  I have javascript which forces the page to do a partial postback OnClientFileUploaded.  The code is firing the wrong "FileUpload" javascript function because it's on the page multiple times and not differentiated.

    How can I update how the javascript is handled so that it knows which FileUploaded function to fire?  Thank you!

    <asp:UpdatePanel runat="server" ChildrenAsTriggers="true">
        <ContentTemplate>
                      <telerik:RadAsyncUpload ID="RadUpload" runat="server" AllowedFileExtensions=".gif,.jpeg,.jpg,.png"  RenderMode="Lightweight" HideFileInput="true"  OnClientFileUploaded="fileUploaded" OnClientValidationFailed="validationFailed" Localization-Select="Upload Image" Skin="Bootstrap"  />
            
            <asp:Button ID="btnTrigger" runat="server" CausesValidation="false" OnClick="btnUpload_Click" style="display:none"  />
    </ContentTemplate>
    </asp:UpdatePanel>

     

    <script type="text/javascript">
     
           function validationFailed(sender,args)
           {
               $('#<%=lbError.ClientID%>').text("Invalid File Type");
               $('#ImageErrorModal').modal('show');
           }
     
           function fileUploaded(sender, args) {
               
               document.getElementById("<%= btnTrigger.ClientID %>").click();
           }
     
           var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
           pageRequestManager.add_endRequest(EndRequestHandler);
           function EndRequestHandler() {
               if ($('#<%=lbError.ClientID%>').text() != "")
                   $('#ImageErrorModal').modal('show');
           }
       </script>

     

Back to Top