Click here to Skip to main content
15,916,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Code project,

I'm using Ajax in ASP .NET Web Application, though I have included AjaxControlToolkit, I'm getting this kind of error while opening the page which has HTML Editor,

XML
Server Error in '/' Application.

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


//this is my code

XML
<%@ Page Title="Para IV Database" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="OurServices_ParaIVPlus.aspx.cs" Inherits="MP.WebForm3" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>

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

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">

        .headerParaIV
        {
            background-color:#804000;
            color:White;
            font-family:Segoe UI Semibold;
            font-size:14px;
            padding:5px;
            margin:2px;
            cursor:pointer;
            border-radius:5px;
        }

        .headerParaIVSelected
        {
            background-color:#7e460d;
            color:White;
            font-family:Segoe UI Semibold;
            font-size:14px;
            padding:5px;
            margin:2px;
            cursor:pointer;
            border-radius:5px;
        }

        .contentParaIV
        {
            font-family:Segoe UI Semibold;
            font-size:14px;
            padding:5px;
        }

    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div id="bannerHeader" class="bannerBgStyle">
        <div id="Div1" class="bannerHeaderStyle">PARA IV <i>Plus</i><sup>TM</sup> Search</div>
        <br /><br />
    </div>

    <br /><br />

    <div>
        <AjaxToolkitControls:Accordion ID="accordion2" runat="server" FadeTransitions="true" TransitionDuration="350"
        HeaderCssClass="headerParaIV" HeaderSelectedCssClass="headerParaIVSelected" ContentCssClass="contentParaIV">
            <Panes>

                <AjaxToolkitControls:AccordionPane ID="bybrandnamepane" runat=server>
                    <Header>Search by Brand Name</Header>
                    <Content>
                        Seacrh by Brand Name <br />
                        <asp:TextBox ID="bybrandnametxt" runat="server"></asp:TextBox>
                    </Content>
                </AjaxToolkitControls:AccordionPane>

                <AjaxToolkitControls:AccordionPane ID="bygenericnamepane" runat=server>
                    <Header>Search by Generic Name</Header>
                    <Content>
                        Seacrh by Generic Name <br />
                        <asp:TextBox ID="bygenericnametxt" runat="server"></asp:TextBox>
                    </Content>
                </AjaxToolkitControls:AccordionPane>

                <AjaxToolkitControls:AccordionPane ID="byadvancesearchpane" runat="server">
                    <Header>Advance Search</Header>
                    <Content>

                    </Content>
                </AjaxToolkitControls:AccordionPane>

                <AjaxToolkitControls:AccordionPane ID="AccordionPane2" runat="server">
                    <Header>Un explored PARA IVs</Header>
                    <Content>

                    </Content>
                </AjaxToolkitControls:AccordionPane>
            </Panes>
        </AjaxToolkitControls:Accordion>
    </div>

    <br /><br />

    <center>
        <div style="height: 486px">
            <asp:Image ID="paraIVimage" runat="server" ImageUrl="~/MP-Images/paraIV.gif"
                Height="273px" />
            <br />

        </div>
    </center>

    <cc1:Editor ID="editor1" runat="server" AutoFocus="true" />
</asp:Content>



I have google this problem but not found the proper solution, so please help me with appropriate solution...
Posted
Updated 26-Oct-12 20:00pm
v2
Comments
vivektiwari97701 27-Oct-12 1:57am    
can u Provide Ur Code...
or just Try
use <%# txtSearchBox.ClientID %>(databinding expression) in place of <%= txtSearchBox.ClientID %> in ur java script

or

just use Iframe

<

iframe src="/HTMLEditor.aspx" frameborder="0" width="730px" height="400px" scrolling="no" marginheight="0" marginwidth="0"

/>
vivektiwari97701 27-Oct-12 2:16am    
ok add Script manager In ur page and remove ur CSS code and check.
if it is working then create external CSS file and link that css File into head section Of your Master Page .if it is not working let me know..
[no name] 27-Oct-12 8:09am    
I have tried all this before, but its really not workin...

1 solution

hello !
there is nothing that might create problem in compilation in the above code.
Every thing is fine.

May be your master page contains some wrong code.
Be sure about all open tag is closed properly and are in the right place.

have fun & enjoy coding!
 
Share this answer
 
Comments
[no name] 28-Oct-12 0:04am    
Nope, except this page rest are the pages working fine..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900