From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I update a graph without refreshing the webpage?

Newbie question for all you ASP.NET / AJAX guru's out there:

Is there any way to refresh a Measurement Studio graph on a webpage without having to refresh the entire page? I'm well-versed with Measurement Studio and Windows Forms, but am fairly new to ASP.NET and web programming.

I'm using Visual Studio 2005 and Measurement Studio 8.01 (and C# if you want to post an example 🙂 )

Thanks,

Shea
0 Kudos
Message 1 of 6
(3,763 Views)

Yes. We provide this as an out of the box experience. There is a control called AutoRefresh (it is in the toolbox). The idea behind this control is it does AJAX updates to the Measurement Studio Controls (actually any control that implements IRefreshCallbackEventHandler, a Measurement Studio interface). To use the control follow these steps:

  1. Drop a AutoRefresh Control onto the page from the toolbox.
  2. Use the smart tag to enable it and click Edit Default Refresh Items. In the collection add the Measurement Studio control you would like updated (set the ItemID property).
  3. If you double click the AutoRefresh control you will get an event handler. This event is executed on the server when the AutoRefresh control does a AJAX update. This is where you graph your data.
  4. Now when you run, you will notice that your graph updates at the interval specified by the AutoRefresh control. Also notice that the entire page is not posting back. Only the graph image is updated.
0 Kudos
Message 2 of 6
(3,755 Views)
Thanks for the tip. I tried the AutoRefresh control, but unfortunately it won't work for our site. We're building an Atlas-enabled site, and any page that has both an Atlas scriptmanager and an AutoRefresh control always results in the following error after a few updates:
"The state information is invalid for this page and might be corrupted"

So far I've tried a few things:
1) using the Atlas UpdatePanel to automatically redraw the graph, but it won't update the graph image - it stays stuck on whatever it drew the first time the page loaded
2) calling ScatterGraph.ClearData() and then re-calling ScatterGraph.PlotXY(), but it still won't update
3) putting the graph into an ASP Placeholder and disposing and reloading it, and again it does the same thing

Is there some C# code we need to directly redraw the graph? Maybe something from the guts of the AutoRefresh control?

Thanks for your help
0 Kudos
Message 3 of 6
(3,747 Views)
Hi Shea24,

Does the AutoRefresh Control work on a site that is not Atlas-enabled?  I am looking into whether we need some additional C# code.

Cheers,
David Goldberg
National Instruments
Applications Engineer
Cheers,

David Goldberg
National Instruments
Applications Engineer
0 Kudos
Message 4 of 6
(3,715 Views)
Yes, it seems to work fine in a non-Atlas site. Although it doesn't appear to be an actual Ajax control - I notice the page refreshing as if it's using a standard ASP postback. Could this be why it's not working with Atlas?
0 Kudos
Message 5 of 6
(3,704 Views)
Hi Shea24,

 You are correct - AutoRefresh is only ASP.NET.  Since Atlas is not released, we have not tested our controls to use that framework.  However, our controls do AJAX through AutoRefresh. This does work for newer browsers.  By following the steps that Brock mentioned earlier, the graph should update without refreshing the page.


Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 6 of 6
(3,687 Views)