AJAX Html Editor Extender upload image appearing blank

天大地大妈咪最大 提交于 2019-12-11 03:01:36

问题


Using AJAX 4 (latest version) I have been working with the html editor extender trying to upload images with text, I have got the Image to upload however it appears blank and when looking at the source, the source of the image is also blank (image below) how do I resolve this upload my selected image?


回答1:


Include in HtmlEditorExtender an event handler for the ImageUploadComplete event.

<ajaxToolkit:HtmlEditorExtender
    OnImageUploadComplete="MyHtmlEditorExtender_ImageUploadComplete"
    ...

Within the ImageUploadComplete event handler, you need to do two things:

1) Save the uploaded image
2) Provide the URL to the saved image so the image can be displayed within the HtmlEditorExtender

protected void MyHtmlEditorExtender_ImageUploadComplete(
     object sender, AjaxFileUploadEventArgs e)
{
     // Generate file path
     string filePath = "~/Images/" + e.FileName;

     // Save uploaded file to the file system
     var ajaxFileUpload = (AjaxFileUpload)sender;
     ajaxFileUpload.SaveAs(MapPath(filePath));

     // Update client with saved image path
     e.PostedUrl = Page.ResolveUrl(filePath);
} 

Make sure you checked http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/HTMLEditorExtender/HTMLEditorExtender.aspx and http://stephenwalther.com/archive/2012/05/01/ajax-control-toolkit-may-2012-release



来源:https://stackoverflow.com/questions/23674893/ajax-html-editor-extender-upload-image-appearing-blank

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!