Saturday, May 25, 2013

HtmlEditorExtender (ASP 4.5)

This Tutorial  about using HtmlEditorExtender in your aspx pages.
Frst of all  HtmlEditorExtender  can be added as extender for a regular textbox control for example :

<asp:TextBox ID="txtMessageBody" runat="server" TextMode="MultiLine" Rows="10" Width="100%"></asp:TextBox>
<ajaxToolkit:HtmlEditorExtender ID="txtMessageBody_HtmlEditorExtender" runat="server" Enabled="True" TargetControlID="txtMessageBody">

but if you try to run your web site the following error will be appeared  : 
"Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider. Otherwise, set the EnableSanitization property to false."

So you have two choices to solve it  : 
First choice :
If your page is not public you can set the EnableSanitization property to false in your HtmlEditorExtender

Second Choice :
  1. Add "HtmlAgilityPack.dll" and  "SanitizerProviders.dll" in your "Bin" Folder
  2. Add The following in Your Web.Config file :
Under Configuration tag  add


<sectionGroup name="system.web">

<section name="sanitizer" requirePermission="false"

type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />




<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">


<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />

<bindingRedirect oldVersion="" newVersion="" />




Under System.Web  tag add 
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">


<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>



Then The Result is



  1. Hi, not only is the website an easy and enjoyable experience for users, but the publishing and transaction environments that sit behind the site are sympathetic to the needs of the business with Web Design Cochin management processes as well as the needs of those who must support and maintain the site.thanks..........

  2. Hi,
    Very simple and helpful article but please also describe howto insert image in HTMl editor extender.