使用AJAX 4(最新版本)我一直在使用html编辑器扩展程序尝试上传带有文本的图像,我已经上传了图像,但它看起来是空白的,当查看源代码时,图像的来源是还空白(如下图所示)如何解决此上传我选择的图像?
答案 0 :(得分:1)
在HtmlEditorExtender中包含ImageUploadComplete事件的事件处理程序。
<ajaxToolkit:HtmlEditorExtender
OnImageUploadComplete="MyHtmlEditorExtender_ImageUploadComplete"
...
在ImageUploadComplete事件处理程序中,您需要做两件事:
1)保存上传的图像
2)提供保存图像的URL,以便可以在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);
}
确保您已选中 http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/HTMLEditorExtender/HTMLEditorExtender.aspx和 http://stephenwalther.com/archive/2012/05/01/ajax-control-toolkit-may-2012-release