Here are the steps to add an Ajax HMTLEditorExtender
control in webform.
- In VS 2013, open Tools > Library Package Manager > Package Manager Console.
- Enter command:
PM> Install-Package AjaxControlToolkit
This will download and add AjaxControlToolkit.dll reference with your website. - Add the following tags in web.config:
<configSections>
<sectionGroup name="system.web">
<section name="sanitizer" requirePermission="false"
type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
</sectionGroup>
</configSections>
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
<providers>
<add name="HtmlAgilityPackSanitizerProvider"
type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
</providers>
</sanitizer>
<configSections>
should be the first child tag of <configuration>
and <sanitizer>
should be a child of <system.web>
tag. Don’t worry about warning at sanitizer
tag. It will work fine.
- In
Site.Master
, replace:
<asp:ScriptManager id ="ScriptManager1"runat="server">
with:
<ajaxToolkit:ToolkitScriptManager ID="ajxToolKit" runat ="server">
This should be added inside form
tag. Remove:
<asp:ScriptReference Name="MsAjaxBundle" />
from script references.
- Now you can add Ajax
HTMLEditorExtender
on webpage. - Here is a sample source of sample content page to add Ajax
HTMLEditorExtender
.
<asp:TextBox ID="txtCategory"
TextMode="MultiLine" Columns="60" Rows="10"
runat="server" />
<ajaxToolkit:HtmlEditorExtender ID="HTMLEditor1" TargetControlID="txtCategory"
runat="server" />
In case the HTMLEditorExtender
is working fine on local machine and after deployment on server, ReflectionTypeLoadException
occurs, then check the trust level. Ajax Tookit requires full trust level to work. Default trust level on server is medium. So, to make ajax toolkit work, change the trust level on server to full
.
This is can be done by adding the following line under <system.web>
section of web.config:
<trust level="Full" />