我想从ajaxtoolkit使用htmleditor。我从this link
下载了工具包Ajax Control Toolkit .NET 3.5
但是收到错误“未在web.config文件中配置Sanitizer提供程序。如果您在公共网站上使用HtmlEditorExtender,请配置Sanitizer提供程序。否则,请将EnableSanitization属性设置为false。 “
的.aspx
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="txtBox1">
</asp:HtmlEditorExtender>
<asp:TextBox runat="server" ID="txtBox1" TextMode="MultiLine" Columns="50" Rows="10"
Text="Hello <b>world!</b>" />
我搜索了很多网站..我得到以下代码作为添加到web.config中的解决方案 但是得到一个错误为“无法加载类型'AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider”。此外还有一行清理剂
<configSections>
<sectionGroup name="system.web">
<section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
</sectionGroup>
</configSections>
<system.web>
<sanitizer defaultProvider="AntiXssSanitizerProvider">
<providers>
<add name="AntiXssSanitizerProvider" type="AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider"></add>
</providers>
</sanitizer>
</system.web>
AjaxControltoolkit
清洁剂提供者文件夹
答案 0 :(得分:2)
使用以下行更改web.config中的sanitizer
部分,然后尝试:
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
<providers>
<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
</providers>
</sanitizer>
答案 1 :(得分:1)
您需要通过Nuget包管理器进行更新.. 所以这个问题都会自动解决。
安装如下在Visual Studio包管理器控制台中:
在以下位置添加新章节:
<configuration>
<configSections>
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" />
</configSections>
....
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.4.9.0" newVersion="1.4.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<ajaxControlToolkit htmlSanitizer="AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer, AjaxControlToolkit.HtmlEditor.Sanitizer" />
</configuration>
答案 2 :(得分:0)
将AjaxControlToolkit.Binary.NET40.zip中的所有文件复制到bin文件夹中。
这是web.config中需要的配置:
<configuration>
<configSections>
...
<sectionGroup name="system.web">
<section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
</sectionGroup>
....
<system.web>
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
<providers>
<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"/>
</providers>
</sanitizer>
在你的aspx文件中:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CommunitySafeApp.Start.WebForm1" %>
<%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager runat="Server" />
<asp:TextBox
ID="txtComments"
TextMode="MultiLine"
Columns="60"
Rows="8"
runat="server" />
<asp:HtmlEditorExtender
TargetControlID="txtComments"
runat="server" />
</div>
</form>
</body>
</html>