Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Controls collection cannot be modified because the control contains code blocks(i.e.<% ...%>) ajax toolkit html editor

<%@ Page Language="C#" MasterPageFile="~/master/111.master" AutoEventWireup="true" CodeFile="Template.aspx.cs" Inherits="_Template" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>


<asp:Content ID="Content3" ContentPlaceHolderID="cphhead" Runat="Server">   
    <script type="text/javascript" src="../css-js/jquery-1.8.3.min.js"></script>
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="cphcontent" Runat="Server">
     <cc1:Editor ID="Editor1" Width="1028px" Height="300px" runat="server" SuppressTabInDesignMode="true" ActiveMode="Design" />                  
</asp:Content>


 <asp:Content ID="Content5" ContentPlaceHolderID="cphFooterJS" Runat="Server">
        </asp:Content>

I try to add master page ajax html editor with namespace but I have this err: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

how to fix it? thanks for your answers.

like image 308
Bip Avatar asked Aug 07 '13 08:08

Bip


2 Answers

I have faced this error before. Solution is, check in your master page, if you have javascript with <% ... %> block, then remove it from head and add in body section.

Hope it helps you.

like image 181
Harshil Raval Avatar answered Nov 20 '22 01:11

Harshil Raval


Use This

1-Replace the code block with <%# instead of <%=

After replace code block with <%# instead of <%= add following code in page load

protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();    
}

After add code run your application it will work for you.

Happy Coding………

like image 9
Mahmoude Elghandour Avatar answered Nov 20 '22 01:11

Mahmoude Elghandour