this.Controls.Add()

  • Thread starter Thread starter Steve Gagliardo
  • Start date Start date
S

Steve Gagliardo

I am developing a series of custom controls which get
added to a parent aspx container using the instruction
this.Controls.Add( myControl ). The parent application
creates an html table dynamically, and for each table row,
adds upwards of seven custom controls per row, which are
initially hidden. Custom controls are displayed based on
buttons the user clicks on a given row. When the
application processes renders table rows in an amount
greater than thirty, the application takes over 30 seconds
to render the entire page. We have used .NET profiler and
have determined the instruction this.Controls.Add(
myCustomControl ) is where execution time is being
consumed. My custom controls are simply c-sharp classes
with a Page_Load handler. These custom classes in turn
render a series of web-based .NET controls.

Why is the instruction this.Controls.Add() performing
slow? I have 1 gig of memory on my workstation.

Steve
 
Hi Steve,

Did this problem occur with a particualr custom control? For example, when
you add it with this.Controls.Add, it run slowly? If you add 30 same custom
controls, will this problem also occur?

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Luke,

Nope. The problem is apparent with all custom controls
added I've implemented. There are three main
this.Controls.Add( myControl ) calls in the top level
page_load. These calls are executed for each table row
rendered. There are thirty table rows in all. Each of the
custom controls added, may in turn nest other custom
controls which are added using this.Controls.Add(
myControl2 ). The .Net profiler has determined that these
calls are suspect and responsible for most of the
execution time. Ultimately the custom controls are
rendering a series of web controls. Now all of the custom
controls have a page_load event which gets called when the
control is added (i.e this.Controls.Add() ). Can I send
you an attachment of a sample custom control? How would I
direct an e-mail of this type using the web-client.

Steve Gagliardo
 
Hi Steve,

With web-client, it is not be able to attach such a big project. To protect
your private code, I recommend you may submit a technial support incodent
for this issue. I think we need to analyst the source code of your custom
web control to find the problem. With a support incodent, this issue may be
resoved in a timely way. For detail, you may browse to:
support.microsoft.com.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top