call LoadControl many times for the same ascx files

H

hohans

Hi,

First, thanks for viewing my post.

Here is my situation. I want to use a web form to generate something
like shipping labels, e.g. 30 labels in each page. So, I have a
Repeater whose ItemTemplate contains a DataList. DataList's
ItemTemplate contains a PlaceHolder. In that PlaceHolder I need to
dynamically add user controls to it. It could be a ascx with address
info or another ascx with membership info. The thing is no matter
which one, I could have to call LoadControl() in OnItemCreated event
for same ascx file up to as many as the labels needed to print. It
slows down the performance a lot.

My question is, in .NET, you call LoadControl() once, can it be cached
in memory so you don't have to load it physically everytime for
subsequent control?

I understand that it could be done by writing a dynamic ItemTemplate.
The case above is simplified. Let's say what if dynamic ItemTemplate
is not an option? Thank you very much!!
 
G

Guest

I would have to do some tinkering to find an answer to your specific
question, but when reading your post I had the following idea:

Instead of a placeholder, you could put one of each of the potential
controls (address, membership, etc.) if there are only a couple and set
visible=false. Then in the OnItemCreated event you could simply FindControl
to the one you want, "initialize" it and then make it visible.
 
H

hohans

Jed,

Thanks for your reply. I am assuming the idea you have is talking
about registering the controls on the page top and making their
visibility on conditional. That sounds like a better approach in terms
of performance. I will give it a try. As far as the way of caching in
memory, I am looking at the ParseControl() function. This guy takes
contents as string and parses it into a control. If I can hold this
control contents in the memory after the first time request ... Hope
that could make some improvement. But I definitely love to hear other
suggestions.

Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top