locked
HtmlEditorExtender image upload error RRS feed

  • Question

  • User-1765597301 posted

    hi

    i'm using an ajax control toolkit HtmlEditorExtender for providing html dynamic page

    but when i try to upload image in it upload erro occures

    here is code

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControlToolkit" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
    
    <!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:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:TextBox ID="replyBody" runat="server" TextMode="MultiLine" Rows="10" Columns="30"/>
        <AjaxToolkit:HtmlEditorExtender ID="replyBody_HtmlEditorExtender" TargetControlID="replyBody"
            DisplaySourceTab="true" OnImageUploadComplete="replyBody_HtmlEditorExtender_ImageUploadComplete"
            ClientIDMode="AutoID" EnableSanitization="true" runat="server">
            <Toolbar>
                <AjaxToolkit:Undo />
                <AjaxToolkit:Redo />
                <AjaxToolkit:Bold />
                <AjaxToolkit:Italic />
                <AjaxToolkit:Underline />
                <AjaxToolkit:StrikeThrough />
                <AjaxToolkit:Subscript />
                <AjaxToolkit:Superscript />
                <AjaxToolkit:JustifyLeft />
                <AjaxToolkit:JustifyCenter />
                <AjaxToolkit:JustifyRight />
                <AjaxToolkit:JustifyFull />
                <AjaxToolkit:InsertOrderedList />
                <AjaxToolkit:InsertUnorderedList />
                <AjaxToolkit:CreateLink />
                <AjaxToolkit:UnLink />
                <AjaxToolkit:RemoveFormat />
                <AjaxToolkit:SelectAll />
                <AjaxToolkit:UnSelect />
                <AjaxToolkit:Delete />
                <AjaxToolkit:Cut />
                <AjaxToolkit:Copy />
                <AjaxToolkit:Paste />
                <AjaxToolkit:BackgroundColorSelector />
                <AjaxToolkit:ForeColorSelector />
                <AjaxToolkit:FontNameSelector />
                <AjaxToolkit:FontSizeSelector />
                <AjaxToolkit:Indent />
                <AjaxToolkit:Outdent />
                <AjaxToolkit:InsertHorizontalRule />
                <AjaxToolkit:HorizontalSeparator />
                <AjaxToolkit:InsertImage />
            </Toolbar>
            
        </AjaxToolkit:HtmlEditorExtender>
        </form>
    </body>
    </html>

    and this is the code behind

    using System;
    using AjaxControlToolkit;
    
    
    public partial class Default2 : System.Web.UI.Page
    {
        protected void replyBody_HtmlEditorExtender_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e)
        {
            string fullPath = "~/Images/Upload_test/" + e.FileName;
            replyBody_HtmlEditorExtender.AjaxFileUpload.SaveAs(Server.MapPath(fullPath));
            e.PostedUrl = fullPath;
    
        }
        protected void Page_Load(object sender, EventArgs e)
        {
           replyBody_HtmlEditorExtender.AjaxFileUpload.AllowedFileTypes = "jpg,jpeg";
        }
    }

    when i want to uload an image, this error occures

    error

    please help me

    Saturday, June 15, 2013 3:47 AM

Answers

  • User1814019480 posted

    HI,

    You need to add this node in your <configuration>.

    <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>

    And add this node into your web<system.web>:

    <httpHandlers>
          <add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
        </httpHandlers>

    And you can refer to those links:

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

    Hope this helps!



     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 20, 2013 5:06 AM

All replies

  • User555306248 posted

    Try to use latest AjaxControltoolkit - http://ajaxcontroltoolkit.codeplex.com/releases/view/107784

    Sunday, June 16, 2013 11:47 PM
  • User-1765597301 posted

    Thanks for answering

    But that was the latest version

    release date 6/9/2013

    Monday, June 17, 2013 1:27 AM
  • User1814019480 posted

          e.PostedUrl = fullPath;
    

    Hi,

    Thanks for posting!

    I think you can change the URl to this:

    e.PostedUrl = Page.ResolveUrl(fullPath);

    you can try it.

    Hope this helps!

    Wednesday, June 19, 2013 2:43 AM
  • User-503402950 posted

    but when i try to upload image in it upload erro occures

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

    Wednesday, June 19, 2013 5:06 AM
  • User-1765597301 posted

    Hi

    the problem is "upload complete does not fire" so i can not save it

    control doesn't  jump to event handler

    Wednesday, June 19, 2013 7:09 AM
  • User1814019480 posted

    HI,

    You need to add this node in your <configuration>.

    <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>

    And add this node into your web<system.web>:

    <httpHandlers>
          <add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
        </httpHandlers>

    And you can refer to those links:

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

    Hope this helps!



     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 20, 2013 5:06 AM