locked
AJAX ToolKit HTML Extender RRS feed

  • Question

  • User1132166131 posted

    Hi Guys,

    I'm using the AJAX HTML Extender for a form in my Web App. I would like to allow users to insert an image from an external URL. But when I add the Insert Image button it brings up the Upload Image dialog Box. This would be fine as a solution but the Upload Box doesn't upload or compile.

    When I try to run my application in Debug mode I get the following error:

    Unhandled exception at line 241, column 5 in http://localhost:56057/Admin/dev/HTML.aspx

    0x800a1391 - JavaScript runtime error: 'ajaxFileUpload_OnUploadComplete' is undefined

    If there is a handler for this exception, the program may be safely continued

    What is the issue here? My Code is as follows;

    <div>
            <cc1:ToolkitScriptManager ID="ScriptManager" runat="server" />
            <cc1:AjaxFileUpload ID="ajaxFileUpload" runat="server" OnClientUploadComplete="ajaxFileUpload_OnUploadComplete" />
        </div>

    C#

    protected void ajaxFileUpload_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
            {
                
                string filePath = "~/Images/" + e.FileName;
                ajaxFileUpload.SaveAs(MapPath(filePath));
            }

    Does any know what is wrong here?

    Tuesday, March 31, 2015 6:06 AM

Answers

  • User1711366110 posted

    tompark

    Any Suggestions, the file upload says it was successful but the image doesn't show up in the HTML Editor nor does it upload to the server. There are no errors given by the web page.

      As per your case , you can replace the following code snippet :

    protected void ajaxFileUpload_OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
    {
    string filePath = @"~\\images\" + e.FileName; var ajaxFileUpload = (AjaxFileUpload)sender; ajaxFileUpload.SaveAs(MapPath(filePath)); e.PostedUrl = Page.ResolveUrl(@"~\\images\" + e.FileName);
    }

    for more information, refer the following links:

    1. Click here to get the sample code with explanation of AJAX HtmlEditorExtender

    2. Click here to get the sample code with explanation of images uploading in AJAX HtmlEditorExtender from similar forum thread
    --
    with regards,
    Edwin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 1, 2015 2:52 AM

All replies

  • User2103319870 posted

    <div> <cc1:ToolkitScriptManager ID="ScriptManager" runat="server" /> <cc1:AjaxFileUpload ID="ajaxFileUpload" runat="server" OnClientUploadComplete="ajaxFileUpload_OnUploadComplete" /> </div>

    I guess ajaxFileUpload_OnUploadComplete  is a severside event, if that is the case then you need to change it like given below

       <cc1:AjaxFileUpload ID="AjaxFileUpload1" runat="server" OnUploadComplete="ajaxFileUpload_OnUploadComplete" />

     

    Tuesday, March 31, 2015 6:20 AM
  • User1132166131 posted

    Hi A2H,

    Thank you for pointing out my mistake! That has worked brilliantly on the AjaxFileUpload. I have just tried to use the following code on the HTML Extender and I can't get it to work.

    <cc1:HtmlEditorExtender ID="HEE_FAQ_Body" DisplaySourceTab="true" OnImageUploadComplete="ajaxFileUpload_OnUploadComplete" EnableSanitization="false" TargetControlID="tbx_kb_Body" runat="server">
                            <Toolbar>
                                <cc1:Copy />
                                <cc1:Paste />                
                                <cc1:Bold />
                                <cc1:Italic />
                                <cc1:Underline />
                                <cc1:JustifyLeft />
                                <cc1:JustifyCenter />
                                <cc1:JustifyRight />
                                <cc1:InsertOrderedList />
                                <cc1:InsertUnorderedList />
                                <cc1:ForeColorSelector />
                                <cc1:FontNameSelector />
                                <cc1:CreateLink />
                                <cc1:InsertImage />
                            </Toolbar>
                        </cc1:HtmlEditorExtender>
                        

    C# Code Behind

     protected void ajaxFileUpload_OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
            {
                string filePath = "~/Images/" + e.FileName;
                var ajaxFileUpload = (AjaxFileUpload)sender;
                ajaxFileUpload.SaveAs(MapPath(filePath));
                e.PostedUrl = Page.ResolveUrl("~/images/" + e.FileName);
            }

    Any Suggestions, the file upload says it was successful but the image doesn't show up in the HTML Editor nor does it upload to the server. There are no errors given by the web page.

    Kind Regards

    Tuesday, March 31, 2015 7:22 AM
  • User1711366110 posted

    tompark

    Any Suggestions, the file upload says it was successful but the image doesn't show up in the HTML Editor nor does it upload to the server. There are no errors given by the web page.

      As per your case , you can replace the following code snippet :

    protected void ajaxFileUpload_OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
    {
    string filePath = @"~\\images\" + e.FileName; var ajaxFileUpload = (AjaxFileUpload)sender; ajaxFileUpload.SaveAs(MapPath(filePath)); e.PostedUrl = Page.ResolveUrl(@"~\\images\" + e.FileName);
    }

    for more information, refer the following links:

    1. Click here to get the sample code with explanation of AJAX HtmlEditorExtender

    2. Click here to get the sample code with explanation of images uploading in AJAX HtmlEditorExtender from similar forum thread
    --
    with regards,
    Edwin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 1, 2015 2:52 AM