How do I create a copy of an asp.net chart?
<p>I'm currently designing a web-based (asp.net/C#) volume tracking tool for a company which is used for reporting and rendering volume data. One way for the user to render data is through using a chart tool which uses the asp.net built-in chart. The user can set plenty of different filtering options to customize his chart appropriately and then have it rendered on the same page. Regarding the contents of the chart everything is working quite alright, however I have created a few controls for giving the user the possibility to generate higher quality images of their graph and show them in a separate window. Using an extension method for Response.Redirect I am redirecting the user to a new window that contains the high resolution version of the chart image, as can be seen below:</p>

<pre><code>private void DownloadImage(int width, int height)
    {
        double scale = width / ViewGraphChart.Width.Value;

        // Resize chart:
        ViewGraphChart.Width = width;
        ViewGraphChart.Height = height;

        // Resize titles:
        foreach (Title t in ViewGraphChart.Titles)
        {
            t.Font = new Font(t.Font.FontFamily, (float)(t.Font.Size * scale), FontStyle.Regular);
        }

        // Resize legends:
        foreach (Legend l in ViewGraphChart.Legends)
        {
            l.Font = new Font(l.Font.FontFamily, (float)(l.Font.Size * scale), FontStyle.Regular);
        }

        UpdateChart();

        // Open image in new window:
        Response.Redirect(ViewGraphChart.CurrentImageLocation, "_blank", "");
    }
</code></pre>

<p>So far so good, a new window opens up and the user is handed a high resolution version of his chart image. The problem is however that the chart in the tool also, naturally, is modified and obviously becomes way too big to properly fit inside the layout. I tried to remedy this by resetting the chart properties right after the redirect, this however made the "HD" chart image show up as the same tiny chart image inside the tool. So, I figured the best way would be to make a copy of the chart, modify the copy and hand it to the user, while the original image remains its small size within the tool. Is there any simple way to do this, considering that I have tons of databindings and other things connected to my chart, or is there some other way to go about?</p>

<p>I'm in somewhat of a hurry so if this came out rather unclear, please tell me and I'll explain more thoroughly.</p>

<p>Regards,
Ante</p>

<p><strong>Edit:</strong></p>

<p>The code behind the Response.Redirect extension method. Borrowed from this very page if I remember correctly.</p>

<pre><code>    public static void Redirect(this HttpResponse response, string url, string target, string windowFeatures) 
    { 
        if 
            ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) 
            &amp;&amp; String.IsNullOrEmpty(windowFeatures)) 
        {
            response.Redirect(url); 
        }
        else
        {
            Page page = (Page)HttpContext.Current.Handler;

            url = page.ResolveClientUrl(url); string script;

            if (!String.IsNullOrEmpty(windowFeatures))
            {
                script = @"window.open(""{0}"", ""{1}"", ""{2}"");";
            }
            else
            {
                script = @"window.open(""{0}"", ""{1}"");";
            }

            script = String.Format(script, url, target, windowFeatures);
            ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);
        } 
    } 
</code></pre>
