|
GetCustomAttr |
Posted by Emilio on Feb-03-2017 01:16 |
|
Hi,
I am implementing the viewport control and am running into an issue with data variables as viewstate is not available.
The chart .aspx page uses a number of complex user controls (.ascx) which contain different properties relating to a series of data to be charted such as which axis, a dataset ID etc.
I am setting custom attributes when drawing the main chart however when the viewport control changes and I catch IsPartialUpdateRequest the GetCustomAttr doesn't return the data (it returns 0)
ChartViewer1.SetCustomAttr("SeriesSettings0.SnapshotOID", ss.SnapshotOID.ToString());
ChartViewer1.GetCustomAttr("SeriesSettings0.SnapshotOID");
Having a look at the source it would seem that the custom attributes are set. I do notice though that there is no * after the value in the name value pair.
<input type='hidden' id='ChartViewer1_JsChartViewerState' name='ChartViewer1_JsChartViewerState' value='32*57031*11503*5202*8001*100*16024**SeriesSettings1.SnapshotOID**206793453x_min**63620962427SeriesSettings0.SeriesName**Amb Air TempSeriesSettings1.SeriesName**Atmos PresSeriesSettings0.Measure_OID**1441151894029336576SeriesSettings0.SnapshotOID**206793453SeriesSettings1.Measure_OID**1441151894012559360x_max**63620962786' />
Please help!
Many Thanks
Emilio |
Re: GetCustomAttr |
Posted by Peter Kwan on Feb-04-2017 04:24 |
|
Hi Emilio,
I have just tried myself and it works normally in my case.
I started with the "Zooming and Scrolling with Viewport Control (Web)" sample code. I modified the "initChartViewer" to add the line:
string temp = "Test Custom Attr: " + DateTime.Now.ToString();
ChartViewer1.SetCustomAttr("SeriesSettings0.SnapshotOID", temp);
Then in the charting code, I put the custom attribute in the chart title so I can see it:
c.addTitle(viewer.GetCustomAttr("SeriesSettings0.SnapshotOID"));
From my testing, the chart title appears the same during partial update, and it displays the date/time when the chart is first created.
For your case, if the "SeriesSettings0.SnapshotOID" is empty during partial update, would you mind to check if there are other code that can clear the attribute? For example, the line:
ChartViewer1.SetCustomAttr("SeriesSettings0.SnapshotOID", ss.SnapshotOID.ToString());
should be run for the initial chart, but should not be run during partial update. If it also runs during partial update, it will overwrite the original attribute, and if can clear the attribute if ss.SnapshotOID.ToString() is empty during partial update. (In my own test code above, the SetCustomAttr is not run during partial update.)
Is there any client side Javascript code that calls SetCustomAttr which may cause the attribute to be cleared?
If the above still cannot solve the problem, is it possible to provide a simple case (perhaps by modifying the original sample code) to help me reproduce the problem?
For your information, besides using custom attributes, there are several methods that can maintain the variables during partial update. These include:
(a) Use Session variables (works if session variables are enabled, which should be the default in ASP.NET).
(b) Use Cookies (only works for short text strings).
Regards
Peter Kwan
|
Re: GetCustomAttr |
Posted by Emilio on Feb-06-2017 18:17 |
|
Perfect, I was setting the attributes during the partial update.
That was the problem!
Thanks |
|