Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 27th, 2010, 05:59 PM
Authorized User
 
Join Date: Mar 2010
Posts: 65
Thanks: 6
Thanked 0 Times in 0 Posts
Default System.web.httpException Error

I have created Table control dynamically added which has link button when clicked , panel control pops up.

I geeting an error:

"The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases"

-It point to the line "Form.controls.add(Panel)". Can somebody help please.

while (reader.Read())
{
TableRow r1 = new TableRow();
TableCell c1 = new TableCell();
TableCell c2 = new TableCell();
TableCell c3 = new TableCell();
c3.Width = Unit.Pixel(160);
LinkButton lnk = new LinkButton();
lnk.Text = "Click me to pop up";
Panel p = new Panel();
Form.Controls.Add(p); //Getting error in this line
p.Height = Unit.Pixel(80);
p.Width = Unit.Pixel(80);
p.BackColor = Color.CornflowerBlue;
AjaxControlToolkit.HoverMenuExtender h = new AjaxControlToolkit.HoverMenuExtender();
Form.Controls.Add(h);// Getting error in this line too
h.TargetControlID = lnk.UniqueID;
h.PopupControlID = p.UniqueID;
c3.Controls.Add(lnk);
c2.Text = reader["RowId"].ToString();
c1.Text = reader["MemPrediction"].ToString();
r1.Cells.Add(c2);
r1.Cells.Add(c1);
r1.Cells.Add(c3);
Tablevar1.Rows.Add(r1);
}
 
Old April 28th, 2010, 05:27 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

It looks like the error is not grumpy with this code, but with when you're running it. Have you tried performing this at an allowed point in the page life cycle?

I like to work programatically myself, and I can confirm that it's a bit grumpy around the edges.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Web.HttpException: Request timed out Ron Howerton General .NET 0 May 21st, 2008 08:23 AM
System.Web.HttpException: Invalid mail attachment kapi.goel C# 4 September 6th, 2007 02:48 AM
Unable to catch error HttpException (0x80004005): Shibu General .NET 6 May 22nd, 2007 04:21 AM
System.Web Error snowy0 VB.NET 2002/2003 Basics 12 October 14th, 2006 11:13 PM
error system.web....... anpham ASP.NET 1.0 and 1.1 Basics 3 July 1st, 2005 01:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.