locked
ASP.NET AJAX HtmlEditorExtender Insert Image RRS feed

  • Question

  • User-688810001 posted

    Hello all, I'm facing some problem with my HtmlEditorExtender Insert Image button.

    When clicked on the button, nothing happens, no popup was shown.

    Tried on both IE and Chrome.

    Helpppp

    Monday, December 30, 2019 2:39 PM

All replies

  • User1535942433 posted

    Hi ASp.net help,

    Accroding to your description,I suggest you could download AjaxControlToolkit.HtmlEditor.Sanitizer in NuGet.It will be configured to use the HtmlAgilityPack Sanitizer Provider.

    Then you could use the ImageUploadComplete event.

    Since you haven't post your codes,I creat a demo for you.

    More details,you could refer to below codes:
    ASPX:

    <div>
                <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                <ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender1"
                TargetControlID="TextBox1" DisplaySourceTab="true"
                runat="server" OnImageUploadComplete="HtmlEditorExtender1_ImageUploadComplete">
                <Toolbar>
                    <ajaxToolkit:InsertImage />
                </Toolbar>
            </ajaxToolkit:HtmlEditorExtender>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </div>
    

    Code-Behind:

    protected void HtmlEditorExtender1_ImageUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
            {
                string fullpath = Server.MapPath("~/image/") + e.FileName;
                HtmlEditorExtender1.AjaxFileUpload.SaveAs(fullpath);
                e.PostedUrl = Page.ResolveUrl("~/image/" + e.FileName);
            }

    Note:
    Web.config:

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

    Result:

    Best regards,

    Yijing Sun

    Tuesday, December 31, 2019 9:54 AM