Image control does not refresh

  • Thread starter Thread starter Sunit Joshi
  • Start date Start date
S

Sunit Joshi

Hello All

I have an image control in main.aspx in a method

BuildImage()
{
//...code..
imgDisks.ImageUrl = "barChart.aspx";

}

This is called whenever the user Clicks on Submit button:

In barChart.aspx I do:
private void Page_Load(object sender, System.EventArgs e)
{
Chart chart = getChart();
Bitmap bitmap = new Bitmap(chart.Width, chart.Height,
PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bitmap);
chart.draw(g);

MemoryStream stream = new MemoryStream();
bitmap.Save(stream, ImageFormat.Png);

Response.Clear();
Response.ContentType = "image/png";
Response.BinaryWrite(stream.ToArray());
g.Dispose();
}

However I still have to sometimes click on submit twice to get the new
image. Any pointers on what might be happening are greatly
appreciated.

thanks
Sunit
(e-mail address removed)
 
It's possible that your page is being loaded from the
cache on the browser.
Try adding junk(random) to the URL and see if that helps.
(i.e. mypage.asps?junk=1340891234809)

HTH,
Suresh.
 
Back
Top