尝试上传图像(本地或服务器上)时的 HtmlEditorExtender 控件向我显示空白,没有显示上传图像的控件,甚至按钮关闭/取消
环境:VS2010 Framework 4.0、AjaxToolKit.dll 4.1.7.123、HtmlAgilityPack.dll 1.4.0.0、SanitizerProviders.dll 1.0.0.0、IIS 7
ASP:
<asp:HtmlEditorExtender ID="HtmlEditorExtender_Nota" runat="server" ClientIDMode="Static"
TargetControlID="txtNota" DisplaySourceTab="true" OnImageUploadComplete="saveFile" >
<Toolbar>
<asp:Undo />
<asp:Redo />
<asp:HorizontalSeparator />
<asp:Bold />
<asp:Italic />
<asp:Underline />
<asp:StrikeThrough />
<asp:HorizontalSeparator />
<asp:Subscript />
<asp:Superscript />
<asp:HorizontalSeparator />
<asp:JustifyLeft />
<asp:JustifyCenter />
<asp:JustifyRight />
<asp:JustifyFull />
<asp:Indent />
<asp:Outdent />
<asp:InsertHorizontalRule />
<asp:HorizontalSeparator />
<asp:InsertOrderedList />
<asp:InsertUnorderedList />
<asp:HorizontalSeparator />
<asp:CreateLink />
<asp:UnLink />
<asp:HorizontalSeparator />
<asp:SelectAll />
<asp:UnSelect />
<asp:HorizontalSeparator />
<asp:RemoveFormat />
<asp:Delete />
<asp:Cut />
<asp:Copy />
<asp:Paste />
<asp:HorizontalSeparator />
<asp:FontNameSelector />
<asp:FontSizeSelector />
<asp:BackgroundColorSelector />
<asp:ForeColorSelector />
<asp:HorizontalSeparator />
<asp:InsertImage />
</Toolbar>
<asp:HtmlEditorExtender>
代码隐藏:
/// <summary>
/// SaveImagen HtmlEditorExtender AjaxControl
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void saveFile(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
if (!Directory.Exists(MapPath(_fileImgNotasPath)))
Directory.CreateDirectory(MapPath(_fileImgNotasPath));
// Generate file path
string filePath = _fileImgNotasPath;
filePath += HttpContext.Current.User.Identity.Name + "_";
filePath += String.Format("{0:ddMMyyyyhhmm}", DateTime.Now);
filePath += e.FileName.Substring(e.FileName.Length - 4, 4);
// 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);
}
网络配置
<system.web>
...
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
<providers>
<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"/>
</providers>
</sanitizer>
...
</system.web>
添加了引用,bin 文件夹中的 dll
这行得通,在某些时候停止工作,并且更新了 AjaxToolKit,什么也没有。所有其他控件都工作:S 仅此部分 InsertImage 可能会发生什么?
帮我超人!!;)