AjaxFileUpload does not fire the OnUploadComplete event

I am trying to get this AjaxFileUpload (used in ContentPage). But it does not OnUploadComplete event on the server side

I am using version 4.1.60919.0 for ControlToolkit. I tried everything I found on the Internet.

Here are just a few steps:

  • Added method enctype = "multipart / form-data" = "post" to the form element in my MasterPage
  • Nested AjaxFileUpload in UpdatePanel with UpdateMode = Always
  • Trial events UploadedComplete and OnUploadComplete, but remained on the second.
  • Added try-catch block in EventHandler to detect unknown exceptions and print ExceptionMessage on a shortcut on the site -> nothing happened
  • Tried with (out) ThrobberImage ...
  • Many other hints that didn't work ...

So, I hope that we find a solution together in this community. Heres my markup:

 <%@ Page Title="New Download" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="NewDownload.aspx.cs" Inherits="Internals_NewDownload" %> 
 <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"> <ajax:ToolkitScriptManager ID="ToolkitscriptManager" runat="server"> </ajax:ToolkitScriptManager> <h1>Create a new Download</h1> <ajax:AjaxFileUpload ID="FileUpload" runat="server" ThrobberID="ThrobberLabel" OnUploadComplete="FileUpload_UploadComplete" /> <asp:Label ID="ThrobberLabel" runat="server" Style="display: none;"><img alt="UploadingPicture" title="Please wait while uploading..." src='<%= Constants.DomainString + "/Data/Images/loading-small.gif" %>' /></asp:Label> <asp:Label ID="DownloadLabel" runat="server"></asp:Label> </asp:Content> 

And this is my CodeBehind:

 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Internals_NewDownload : System.Web.UI.Page { private string m_LanguageCode; protected void Page_Load(object sender, EventArgs e) { if (RouteData.Values.ContainsKey("LanguageCode")) m_LanguageCode = RouteData.Values["LanguageCode"].ToString(); //if (IsPostBack) // return; if (!User.IsInRole("Administrator") && !User.IsInRole("Kunde") && !User.IsInRole("Mitarbeiter")) Response.Redirect(Constants.DomainString + "/PermissionDenied.aspx"); Session[Constants.NonGlobalizedString] = true; Session[Constants.MenuInfoSession] = new ClsMenuInfo("NewDownload"); } protected void FileUpload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { try { string filePath = "~/upload/" + e.FileName; DownloadLabel.Text = filePath; } catch (Exception ex) { DownloadLabel.Text = ex.Message; } } } 

Please, if you have ANY idea, feel free to let me know about it. I am very confused as I think what I just did in what I found on the Internet ...

Thanks in advance!

+6
source share
1 answer

Note that AjaxFileUpload control uses the contextkey QueryString parameter to detect its own postback. I believe the reason for your question is that this parameter was lost as a result of rewriting url. I am not an expert in the application of routing, but, in my opinion, you need to register the contextkey parameter in the routing tables and configure the AjaxControlToolkit sources to use RouteData instead of Request.QueryString to get the value. Check this link for more information: AjaxControlToolkit source code

0
source

All Articles