Understanding Drawing and Download As Image

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
cjherasmus
Newbie
Newbie
Posts: 7
Joined: Mon Mar 20, 2023 12:00 am

Understanding Drawing and Download As Image

Post by cjherasmus » Fri May 26, 2023 12:54 pm

Hi,

I'm trying to understand why my chart is downloaded empty if I put the "drawing" code in a button event vs. putting it in the page load event. See attached example.

If the chart code is in the page-load event and I click the download button the chart with the data series is downloaded.
If the chart code is in the button-click event and I click the download button the chart without the data series is downloaded.

Thank you.
Attachments
WebApplication1.zip
(8.25 KiB) Downloaded 237 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Understanding Drawing and Download As Image

Post by Christopher » Wed May 31, 2023 2:18 pm

Key points to remember.
  • The Webform app is stateless and has no session memory although it is possible to ‘carry’ session memory by using “sessions” or via ViewState… (comments below).
  • Page_load is always called, but not the button code (only called when pressed) … so for every call first an empty page is loaded then page_load is called and then any button code is called
With those points in mind, every new call to the server has no knowledge of any previous call and starts from zero. In this case a call could be made to DrawChart from the button code that generates the PNG and it will return the chart but as the response is set as a png file, the chart itself isn’t rendered on the web page.

An extra point to note, when a button is actuated a page_load occurs followed by the button call method. The session is fluid between them and the chart thus shows six bars if both the page_load and the Buttonxx_Click contain a call to DrawChart.

-------

Possible solutions to carry state:

Use either:
Viewstate to carry data across calls.
See: https://www.c-sharpcorner.com/UploadFil ... Asp-Net53/

Or session; see example here:
https://github.com/Steema/TeeChart-NET- ... rt.aspx.cs

(here used to track a chart zoom to permit incremental zooms)
https://www.steema.net/TeeChartForNET/I ... Chart.aspx
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

cjherasmus
Newbie
Newbie
Posts: 7
Joined: Mon Mar 20, 2023 12:00 am

Re: Understanding Drawing and Download As Image

Post by cjherasmus » Tue Jun 06, 2023 7:49 am

Thanks for the refresher.

Got it to work, thank you.

Post Reply