Search code examples
c#asp.netajaxajaxcontroltoolkithtml-editor

AjaxControlToolKit: HTML Editor (Unknown Server Tag)


I am going to add the HTML editor and the code is following

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
    <%@ Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
  <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" />

        <asp:TextBox
        ID="txtComments"
        TextMode="MultiLine"
        Columns="60"
        Rows="8"
        runat="server" />

<asp:HtmlEditorExtender
        TargetControlID="txtComments"
        runat="server" />
</asp:Content>

But it is giving the error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'asp:HtmlEditorExtender'.

Help me.


Solution

  • change TagPrefix

      <%@ Register TagPrefix="ajaxToolkit" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
    

    and

    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" />
    

    then

    <ajaxToolkit:HtmlEditorExtender
            TargetControlID="txtComments"
            runat="server" />
    

    it should work.

    if you have ScriptManager on your master page you don't need to add it on content pages. And also when you using ToolkitScriptManager you don't need defaut ScriptManager.

    UPDATE:

    Check in your web config for AjaxControlToolkit tagPrefix as bellow.

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <pages>
          <controls>
            <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
          </controls>
        </pages>
      </system.web>
    </configuration>
    

    if it is there when you drag and drop controls will insert with correct tag prefix.

    try to add ajax toolkit with nuget, by using Package Manager Console. You can enter the command Install-Package AjaxControlToolkit in the console to install the Ajax ControlToolkit