Ajax File Upload Not firing the OnUploadComplete on the Webserver

989 views Asked by At

Ajax File Upload works fine at the localhost level, but when I build it to the Development web server, the OnUploadComplete doesn't fire.

The .aspx page:

<body>
<form id="form1" runat="server">
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <cc1:AjaxFileUpload ID="AjaxFileUpload1" runat="server" 
        onuploadcomplete="AjaxFileUpload1_UploadComplete" />
</div>
</form>
</body>

The codebehind file:

public partial class Ajaxtest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string filePath = string.Empty;
        try
        {
            filePath = (Server.MapPath("~/Images/") + Guid.NewGuid() + System.IO.Path.GetFileName(e.FileName));
            AjaxFileUpload1.SaveAs(filePath);
            e.DeleteTemporaryData();

        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }
}

web config :

<system.web>
   <httpHandlers>
   <add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
   </httpHandlers>
      </system.web>
<system.webServer>
  <validation validateIntegratedModeConfiguration="false"/>
  <handlers>
  <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
  </handlers>
  </system.webServer>
1

There are 1 answers

0
Surendar On

You have to put the below code in your aspx page or master page if any.

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>