"control contains code blocks" error appears with ajax panel

2 posts, 0 answers
  1. Shrikant Kale
    Shrikant Kale avatar
    20 posts
    Member since:
    Oct 2009

    Posted 05 Feb 2010 Link to this post

    Hi Telerik team,

    I am facing one problem with use of RadAjaxPanel. I have following code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxPanel.aspx.cs" Inherits="WebApplication10.AjaxPanel" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"
        <title></title
    </head> 
    <body> 
        <form id="form1" runat="server"
        <div> 
        <img src="<%= MyServer + "images/uparrow.gif"%>/> 
        <telerik:RadScriptManager ID="mgr1" runat="server"></telerik:RadScriptManager> 
        <telerik:RadAjaxPanel ID="panel1" runat="server"></telerik:RadAjaxPanel> 
        </div> 
        </form> 
    </body> 
    </html> 
    ================================== 
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
     
    namespace WebApplication10 
        public partial class AjaxPanel : System.Web.UI.Page 
        { 
            public string MyServer { get { return "http://server/"; } } 
            protected void Page_Load(object sender, EventArgs e) 
            { 
     
            } 
        } 

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

    If I wrap RadAjaxPanel in another div(server control) then code works as expected.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxPanel.aspx.cs" Inherits="WebApplication10.AjaxPanel" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server"
        <title></title
    </head> 
    <body> 
        <form id="form1" runat="server"
        <div> 
        <img src="<%= MyServer + "images/uparrow.gif"%>/> 
        <telerik:RadScriptManager ID="mgr1" runat="server"></telerik:RadScriptManager> 
        <div id="wrapper" runat="server"
        <telerik:RadAjaxPanel ID="panel1" runat="server"></telerik:RadAjaxPanel> 
        </div> 
        </div> 
        </form> 
    </body> 
    </html> 
     

    So I have a working solution for such problem, But can anyone provide more insight into this?

    Regards
    Shrikant


  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 05 Feb 2010 Link to this post

    Hello Shrikant,

    For more information about how to avoid this error I suggest you review the following help article, which elaborates on this matter: 
    RadCodeBlock and RadScriptBlock

    Best wishes,
    Pavlina
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top