views:

42

answers:

2

So we have this legacy code that displays data in a tree format. They pad each node of the tree using spacer images (...yup..ugh)

Unfortunately, the use of these images is controlled by an in-house UserControl that we're forced to use (basically just derives from Web.UI.WebControls.Image, though).

Well, turns out we have a HUGE tree with thousands of nodes, each one four levels deep or more. This means we're creating about 10,000 padding images each time we draw the page, which is taking up quite a bit of time.

My solution right now is to statically pre-allocate a large number of these Images and use those. I'm hoping there isn't any nastiness that will crop up when multiple users access the page at the same time.

However...is there any way to reuse a UserControl such that we could create just a SINGLE instance of the Image and somehow add it multiple times to the Controls collections? I tried this naively and it didn't work. The image only gets drawn a single time, for the first control it's added to the first time (probably something to do with INamingConainer stuff...?)

A: 

Hi Klye K,

Have you considered loading the contents of the tree in a backgound thread?

Cheers,

Antony

Antony Gibbs
Unfortunately I don't think that would help much. The problem is overall page loading time and user experience. Generating those 10k Image controls is dominating everything else time-wise.
Kyle K
+1  A: 

Just an idea, but can you not just replace the Padding Image User Control with a different user control, such as:

public DivPadder : HtmlGenericControl
{
    public DivPadder() : base("div")
    {
        this.Style.Add("padding:10px");
    }
}
GenericTypeTea