473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# Ajax Error : The Controls collection cannot be modified.

487 Expert 256MB
I am adding dynamic controls in my page through a panel as figured below.
Expand|Select|Wrap|Line Numbers
  1. pnlModel.ID = "pnlDyModel";
  2.             pnlModel.Controls.Add(lblReportTitle);
  3.             pnlModel.Controls.Add(new LiteralControl("<br />"));
  4.             pnlModel.Controls.Add(txtReport);
  5.             pnlModel.BackColor = System.Drawing.Color.LightBlue;
  6.             pnlModel.Width = 580;
  7.             pnlModel.Controls.Add(tblInPanel);            
  8.             this.Page.Form.Controls.Add(pnlModel);//Error Part
Here I am getting error like.
Error:
Message="The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."

Source="System.Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.UI.ControlCollection.RemoveAt(Int32 index)
at System.Web.UI.ControlCollection.Remove(Control value)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at CommunityForum.OnInit(EventArgs e) in e:\Hari\AJAX Samples\MyProject\MyPage.aspx.cs:line 101
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Can any one point me how to solve it.
May 20 '08 #1
2 1988
Plater
7,872 Expert 4TB
I would guess it doesn't like adding literal controls?
May 20 '08 #2
CyberSoftHari
487 Expert 256MB
Already I checked removing that but, Throwing same error.
Sorry, forget to point this.
May 20 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeff Dockman | last post by:
Background: We needed the ability to create a templated web site that may change in layout from installation to installation. To accomplish this, we created a base Page class that all pages in...
2
by: Axel Dahmen | last post by:
HI, I want to dynamically add controls to a web page from within a common base class. Unfortunately, ASP.NET fails with "System.Web.HttpException: The Controls collection cannot be modified...
0
by: Mortar | last post by:
i am dynamically creating controls when i do a server side export to an excel file. I can only get it to work if I have no <% %> anywhere in my html. i.e. i am writing out session name to the...
66
by: Cor | last post by:
Hi, I start a new thread about a discussion from yesterday (or for some of us this morning). It was a not so nice discussion about dynamically removing controls from a panel or what ever. It...
0
by: Zimmergren | last post by:
I know this has been up on googlegroups before, on several places. However, I havn't found a solution to this specific problem. I get this errormessage: "The Controls collection cannot be...
31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
0
by: forumaic | last post by:
Hello, I am trying to export data to excel from datagrid, and I am getting an error: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." ...
1
by: John Straumann | last post by:
Hello all: I am a CRM Solution Architect so not a .NET expert by any means. I am working with a customer who needs to modify the Advanced find in CRM which works as shown here: ...
1
by: Yan | last post by:
Hi, I'm apparently far from being the 1st one to meet this error... My asp.net ajax page requires ScriptManager.axd but gets a 404. following a lot of "This is how I solved it" posts, I : -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.