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

Multiple RadAsync controls w/Javascript

0 Answers 52 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 11 Apr 2018, 07:01 PM

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>

 

No answers yet. Maybe you can help?

Tags
AsyncUpload
Asked by
Angie
Top achievements
Rank 1
Share this question
or