Search code examples
c#asp.nethtmleditorextender

HtmlEditorExtender Image Upload Error in asp.net


I've encountered an error when uploading an image using htmleditorextender.

Below is the error message:

pics.png (image/png) - 616.51 kb (error)

Below is the code that I used in code behind.

protected void HtmlEditorExtender3_ImageUploadComplete(object sender, AjaxFileUploadEventArgs e)
{
    string fullpath = Server.MapPath("~/pictures/") + e.FileName;
    HtmlEditorExtender3.AjaxFileUpload.SaveAs(fullpath);
    e.PostedUrl = Page.ResolveUrl("~/pictures/") + e.FileName;

}

And below is my code in the aspx page.

<asp:HtmlEditorExtender TargetControlID="Textbox1" ID="HtmlEditorExtender3" runat="server" DisplaySourceTab="true" EnableSanitization="False"  OnImageUploadComplete="HtmlEditorExtender3_ImageUploadComplete">
                            <Toolbar>
                                <asp:Undo />
                                <asp:Redo />
                                <asp:Bold />
                                <asp:Italic />
                                <asp:Underline />
                                <asp:InsertUnorderedList />
                                <asp:ForeColorSelector />
                                <asp:JustifyLeft />
                                <asp:JustifyCenter />
                                <asp:JustifyRight />
                                <asp:CreateLink />
                                <asp:InsertImage/>
                            </Toolbar>
                        </asp:HtmlEditorExtender>

Also , I've noticed that it does not also go to the debug part. When I use debugging.


Solution

  • I already solve it guys. What I did is to make some few changes in my web.Config file.

    Below are the changes that I made:

    1. <system.web>
        <trust level="Full"/>
       </system.web>
    
    2. <remove name="AjaxFileUploadHandler" />
          <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />