locked
AjaxFileupload control not showing properly RRS feed

  • Question

  • User1835401063 posted

    Hello

    I want to use any kind of file upload control in an updatepanel and a customized panel inside of that update panel. First I used asp.net file upload which nrever rised any "Upload Complete" event. After searching this forum, I reached to the conclusion that this control is not compatible with updatepanel. Then I switched to AjaxFileUpload. at first it used to rais the exception: "AjaxFileUpload.cs not found" when I wanted to save the uploaded file in uploadcomplete event. After I couldn't find a solution in forums, I thought newer versions of ajaxcontrol toolkit may solve the problem. Long story made short: From that time on, in any combination of versions of visual studio, .net framework and ajaxcontroltoolkit, this fileupload control is rendered like only a small black stripe. (I have screen shot of this shape but I don't know how to upload here). In design mode rendering of control is OK.

    May any one help?

    thanks

     

    Tuesday, January 7, 2014 3:24 PM

Answers

  • User-933407369 posted

    hi,

    i would suggest you check out your web.config, as shown below:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" maxRequestLength="42949672" />
        <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>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="4294967295"/>
          </requestFiltering>
        </security>
      </system.webServer>
    </configuration>
    

    Please refer to the links below:

    April 2013 Release of the Ajax Control Toolkit

    http://stephenwalther.com/archive/2013/04/30/april-2013-release-of-the-ajax-control-toolkit

    Resolved: AjaxFileUploader April 2013 Upload Error

    http://ajaxcontroltoolkit.codeplex.com/workitem/27416

    if it is not working for you,I suggest that you can consult your issue on ASP.NET Ajax forum: http://ajaxcontroltoolkit.codeplex.com/workitem/list/basic  for better solution and support. Ajax  Experts there will further research this issue and provide you better support.

    Thank you for your understanding.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 16, 2014 12:47 AM

All replies

  • User1734617369 posted

    Hi,

    Could you provide the code of the page that you are having problem with?

    Best regards
    Johan

    Wednesday, January 8, 2014 3:39 AM
  • User555306248 posted

    Refer this

    http://stephenwalther.com/blog/archive/2012/05/01/ajax-control-toolkit-may-2012-release.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ajaxfileupload.aspx.cs" Inherits="ajaxfileupload" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <div>
        <asp:Label runat="server" ID="myThrobber" Style="display: none;"><img align="absmiddle" alt="" src="images/uploading.gif"/></asp:Label>
            <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
                onuploadcomplete="AjaxFileUpload1_UploadComplete" ThrobberID="myThrobber" MaximumNumberOfFiles="10" AllowedFileTypes="jpg,jpeg"/>
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.IO;
    
    public partial class ajaxfileupload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
        protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            string filePath = "~/upload/" + e.FileName;
            AjaxFileUpload1.SaveAs(filePath);
    
        }
    }
    
    

    Wednesday, January 8, 2014 10:57 PM
  • User1835401063 posted

    this is the code part that has problems, I had to make a new page because my main page was excessively complecated

    I added the toolkitscriptmanager afer receiving the following comment from Chetan.Sarod. Adding this control together with scriptmanager and uploadpanel results in software looking for ajaxfileupload.cs again. without any of toolkitscriptmanager or scriptmanager, I see that black stripe again.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="HTTP_2012.WebForm1" %>
    
    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                    </asp:ToolkitScriptManager>
    <br />
                    <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" />
    <br />
                </ContentTemplate>
            </asp:UpdatePanel>
        
        </div>
        </form>
    </body>
    </html>
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace HTTP_2012
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
        }
    }

    Thursday, January 9, 2014 1:25 AM
  • User1734617369 posted

    Hi,

    You can not have both a ScriptManager and a ToolkitScriptManager on the same page, and to make the AjaxFileUpload work you should use the ToolkitScriptManager, i e like this:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
             <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
             </asp:ToolkitScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>               
                    <asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        </form>
    </body>
    </html>

    Hope this helps!

    Best regards
    Johan

    Thursday, January 9, 2014 4:19 AM
  • User1835401063 posted

    no way, unfortunately it didn't help. It only showed the small black stripe.

    Thursday, January 9, 2014 11:44 AM
  • User1734617369 posted

    Hi,

    So if you try the example that I gave it is just showing the black stripe? Which version of the toolkit do you use and is the problem the same in all browers?

    /Johan

    Friday, January 10, 2014 4:38 AM
  • User1835401063 posted

    Hi

    Toolkit version is 4.1.7.1213 published on Dec.14.2013. Language is "Neutral" and I downloaded it directly from Codeplex. I'm not sure if version information gives you data about underlying .net library of toolbox since I've forgotten which version of .net is this toolkit for. 

    I've also added my web.config file here as it may be of help:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>
        <clear />
        <add name="ApplicationServices" connectionString="Data Source=*.*.*.*\sqlexpress2008r2;Initial Catalog=**;Persist Security Info=True;User ID=**;Password=**" providerName="System.Data.SqlClient" />
        <add name="Entities" connectionString="metadata=res://*/Pages.Model1.csdl|res://*/Pages.Model1.ssdl|res://*/Pages.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=**\sqlexpress2008r2;initial catalog=**;persist security info=True;user id=**;password=**;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.5">
          <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
        <httpRuntime targetFramework="4.5" />
        <pages>
          <namespaces>
            <add namespace="System.Web.Optimization" />
          </namespaces>
          <controls>
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
          </controls>
        </pages>
        <authentication mode="Forms">
          <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
        </authentication>
        <profile defaultProvider="DefaultProfileProvider">
          <providers>
            <clear />
            <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" />
          </providers>
          <properties>
            <add name="Language" defaultValue="EN" allowAnonymous="false" type="string"/>
          </properties>
        </profile>
        <membership defaultProvider="AspNetSqlMembershipProvider">
          <providers>
            <clear />
            <add name="AspNetSqlMembershipProvider" type="mine.Account.EmailAsUsernameMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
            <!--add name="AspNetSqlMembershipProvider" type="mine.Account.EmailAsUsernameMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /-->
          </providers>
        </membership>
        <roleManager defaultProvider="DefaultRoleProvider">
          <providers>
            <clear />
            <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" applicationName="/" />
          </providers>
        </roleManager>
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
          <providers>
            <clear />
            <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ApplicationServices" />
          </providers>
        </sessionState>
      </system.web>
      <system.net>
        <mailSettings>
          <smtp>
            <network defaultCredentials="false" host="****" port="25" userName="*****" password="****" />
          </smtp>
        </mailSettings>
      </system.net>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
            <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
            <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
    </configuration>

    and, yes, problem is the same in all browsers.

    Thanks

    Friday, January 10, 2014 4:44 PM
  • User1734617369 posted

    Hi,

    Ok, according to the version number of the toolkit you are using the version created for .Net 4.0 but your solution is for .Net 4.5 so the next thing to try is to download the toolkit made for .Net 4.5 and see if that helps!

    /Johan

    Friday, January 10, 2014 5:16 PM
  • User1835401063 posted

    For last few days I was busy with versions. .net 4.5 seems to have more bugs. in the middle of struggling with Ajax, project stopped connecting to sql server. I reinstalled .net 4.5 and 4.51 and developers pack, then downgraded my project to .net 4.0 with ajax 4 and all problems including ajax and database connection solved.

    Another change that I've made was this time was I added reference to all dlls in ajaxcontroltoolkit. before this problem I used to add reference only to main dll file and it used to work. I don't know which of these changes really solved the problem but I'm sure I will stay away from 4.5 these days.

    I don't know if this is correct to aske another question under this topic or not? the control doesn't keep the temporary file in relevant temp directory and after uploadcomplete event raised, the SaveAs method throws an exception that it can't find temp file.

    Monday, January 13, 2014 2:11 PM
  • User-933407369 posted

    hi,

    i would suggest you check out your web.config, as shown below:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" maxRequestLength="42949672" />
        <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>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="4294967295"/>
          </requestFiltering>
        </security>
      </system.webServer>
    </configuration>
    

    Please refer to the links below:

    April 2013 Release of the Ajax Control Toolkit

    http://stephenwalther.com/archive/2013/04/30/april-2013-release-of-the-ajax-control-toolkit

    Resolved: AjaxFileUploader April 2013 Upload Error

    http://ajaxcontroltoolkit.codeplex.com/workitem/27416

    if it is not working for you,I suggest that you can consult your issue on ASP.NET Ajax forum: http://ajaxcontroltoolkit.codeplex.com/workitem/list/basic  for better solution and support. Ajax  Experts there will further research this issue and provide you better support.

    Thank you for your understanding.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 16, 2014 12:47 AM