Call AjaxFileUpload OnUploadComplete event on another Button click event using C# and jQuery in ASP.NetAsk Questions

 Posted on 10/16/2019


need help to upload images by drag and drop in c# on asp button click have tried with ajax upload but no go.

the ajax uploadfile has its own upload button but i need to do it on asp button.

Share On: facebook gplus twitter
Asked by Walter Tross on 10/16/2019 Score: 24 points
Add Comment:


2 Answers

0 Corrected Answers
Aproved Answers
Answered by hardik chaudhary on 10/21/2019 8:14:08 AM Score: 557 points

hi thank you for your help.

it is working fine as expected however i used ur logic in a diff way

function validate() {

       if ($(".ajax__fileupload_fileItemInfo").length > 0) {

           alert('file exist');

           // $('.ContentPlaceHolder1_AjaxFileUpload1_UploadOrCancelButton').hide();




           return true;



       else {

           alert('select your file');

           return false;



and called it on button client upload.


Add Comment:
Aproved Answers
Answered by Helder Sepulveda on 10/16/2019 9:07:53 AM Score: 58 points

Check with below:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="">
<head runat="server">
    <style type="text/css">
            font-family: Arial;
            font-size: 10pt;
    <script type="text/javascript" src=""></script>
    <form id="form1" runat="server">
    <asp:ToolkitScriptManager runat="server">
    <asp:AjaxFileUpload ID="AjaxFileUpload11" runat="server" MaximumNumberOfFiles="5"
        Width="400px" OnUploadComplete="OnUploadComplete" />
    <asp:Button Text="Save" runat="server" OnClick="Save" />
    <input type="submit" value="Custom Upload Button" runat="server" onserverclick="Save"
        onclick="$('.ajax__fileupload_uploadbutton').trigger('click');" />


protected void OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
    string fileName = Path.GetFileName(e.FileName);
    AjaxFileUpload11.SaveAs(Server.MapPath("~/Uploads/" + fileName));

protected void Save(object sender, EventArgs e)


But Button click event is raised first and then OnUploadComplete event will be raised.


Add Comment:

Post Your Answers

Existing Members

Sign in to your account
Email Address
New Member?
Sign up and complete profile
Full Name
Email Address
I have read and agree to the Terms of Service and Privacy Policy
Please subscribe me to the StoodQ newsletters
Guideline to answer a question:

Useful tips to submit your answer
Please read below guidelines before you submit your answer for question.

  • Read and understand question for which you are submitting your answer.
  • Try to avoid grammatical and spell mistake while answering.
  • Do not post any irrelevant information in your answer.
  • Explain your answer with example or any reference link to help who posted question.
  • If you find irrelevant question, please report it to support. Click here to contact support.
  • You agree to the privacy policy and terms of use to submit any contents.

Note: StoodQ is online developers community which helps developer for their difficulty, lets help them with your value contribution.