locked
MasterPage.master and Site.master RRS feed

  • Question

  • User2082459863 posted

    I used both MasterPage.maste and Site.master for different webpage. It seems work fine. When I used ajax on the pages, it works with MasterPage.master, but it throws error on the pages with Site.master.

    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. <% ... %>).

    However, I'm not clear the difference of two. Can you explain it? or point to a post?

    Thanks,

    Tuesday, January 28, 2014 3:48 PM

Answers

  • User2082459863 posted

    I have two line in the testing code:

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

    <cc1:Editor ID="edDescription" runat="server" />

    By testing, it turns out that 

    <cc1:Editor ID="edDescription" runat="server" />

    cause the error. I used div instead of table right now. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 28, 2014 6:00 PM

All replies

  • User-760709272 posted

    I'm guess on the one that doesn't work you have "runat=server" on the <head> tag and have an asp script block inside it like

    <% if (something) %>

    or whatever, and are maybe adding a script or link tag to it in your code in order to dynamically include files.  Well you can't do that to controls that have <% %> blocks inside them.

    Tuesday, January 28, 2014 3:58 PM
  • User2082459863 posted

    Here is the simple test page using Site.master. It seems it doesn't recognize register code throwing error.

    <%@ Register Assembly
    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="event-test.aspx.cs" Inherits="events_event_test" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="cPPage" Runat="Server">
    
    <div class="pagewidth default" >
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <br />
    <cc1:Editor ID="edDescription" runat="server" />
    </div>
    </asp:Content>
    



    Tuesday, January 28, 2014 4:34 PM
  • User465171450 posted

    The register assembly should have nothing to do with it. What's in the Site.Master file? This is just a .aspx page so if there is some reason this would work with one master but not another, then there is most likely something in the problem master not the .aspx page.

    Tuesday, January 28, 2014 5:21 PM
  • Tuesday, January 28, 2014 5:41 PM
  • User2082459863 posted

    I have two line in the testing code:

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

    <cc1:Editor ID="edDescription" runat="server" />

    By testing, it turns out that 

    <cc1:Editor ID="edDescription" runat="server" />

    cause the error. I used div instead of table right now. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 28, 2014 6:00 PM