Jump to content
Software FX Community

Losing statistical extension on postback!


User (Legacy)

Recommended Posts

Hi,

I am having a strange problem with ChartFX .NET WebForms and Statistical

Extensions.

First of all, my Chart control is programmatically created as a child

control of a custom composite chart control. This is necessary to fit

into my component-based web architecture.

My composite chart control works great, but something strange happens

when I add the statistical extension, after the first load, on

subsequent postbacks.

I am instantiating the Chart object in an overloaded

CreateChildControls, so I know it is there before any postbacks are

processed. As soon as it is allocated, I create the Statistics object

and assign the Chart to the statistics object.

After the chart dataset has been loaded (in OnPreRender), I add some

studies, enable the statistics legend, and it works!

But if I postback to the page, on subsequent page loads, the statistics

is no longer available. In addition, Statistics.LegendObj property is null.

If I set Chart.EnableViewState = false, I do not have this problem.

But, I would like to keep the view state! How can I keep the view state

and make the statistics extension work?

Please advise,

CM

Link to comment
Share on other sites

When you say the chart looses the statistical extension do you mean that the

chart picture that is returned to the browser has no statistics on it ?

One key thing to consider is this:

The Statistical extension is not a Control so it DOES NOT participate in the

serialization (ViewState) by itself [i]. When attached to the chart, the

chat object will save it inside its own ViewState.

When the Postback comes, the chart is re-initialized from the ViewState and

an NEW instance of the statistical extension will be created and initialized

from the ViewState, however this new Statistical object is not "linked" to

your variable because the serialization was done by Chart FX not by ASP.NET

(because of [i]).

What you need to do is call Extensions.Find to locate the statistical

extension already attached to the chart after the ViewState is loaded and

then assign it to your variable.

Now, all this I'm saying I have done with the chart directly on a form.

Because you have a container control on top of it, the timing will be a

little different. If you post a the code of simple Web Control container

that reproduces the problem I can help you determine what the problem is.

--

FP

Software FX

Link to comment
Share on other sites

That did the trick -- after changing my component control to look for 

the existing Statistics object in the ExtensionManager, rather than

allocate it every time, it works great!

Thank you for your help!

CM

SoftwareFX Support wrote:

> When you say the chart looses the statistical extension do you mean that the

> chart picture that is returned to the browser has no statistics on it ?

>

> One key thing to consider is this:

>

> The Statistical extension is not a Control so it DOES NOT participate in the

> serialization (ViewState) by itself [i]. When attached to the chart, the

> chat object will save it inside its own ViewState.

>

> When the Postback comes, the chart is re-initialized from the ViewState and

> an NEW instance of the statistical extension will be created and initialized

> from the ViewState, however this new Statistical object is not "linked" to

> your variable because the serialization was done by Chart FX not by ASP.NET

> (because of [i]).

>

> What you need to do is call Extensions.Find to locate the statistical

> extension already attached to the chart after the ViewState is loaded and

> then assign it to your variable.

>

> Now, all this I'm saying I have done with the chart directly on a form.

> Because you have a container control on top of it, the timing will be a

> little different. If you post a the code of simple Web Control container

> that reproduces the problem I can help you determine what the problem is.

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...