This is a migrated thread and some comments may be shown as answers.

"control contains code blocks" error appears with ajax panel

1 Answer 57 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Shrikant Kale
Top achievements
Rank 1
Shrikant Kale asked on 05 Feb 2010, 12:25 PM
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


1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 Feb 2010, 04:11 PM
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.
Tags
Ajax
Asked by
Shrikant Kale
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or