Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Web Form , Timer and Gauge Control

Hello, I'm working on a web page that should fetch a value from a database and show this value on the NI Measurement Studio Gauge control. The database is updated every second, so the Gauge control has to be updated every second. This is a necessary requirement. My initial idea was to use an "AJAX Timer" control and set the the interval to one second and place the code to update the Gauge value in the timer's tick event. Though this method works, it's not very good because this forces the web browser to do a "full refresh" of the web page every second. Is there any way of getting around this "full refresh" that the Timer control causes ? Best regards, Seb
0 Kudos
Message 1 of 2
(3,893 Views)
Hi MadSeb,

Before I begin, I wanted to first mention that Measurement Studio doesn't currently support ASP.NET AJAX. However, we will be supporting AJAX in the near future so be on the lookout. 

So what is your option for now? Well, you can use our AutoRefresh control that is found in the Toolbox.  You can see an example of this in the Measurement Studio ASP.NET Demonstration Gallery.  The basic idea behind the AutoRefresh control is that it uses the ASP.NET client callback architecture to update a control or a group of controls at a specified interval. Behind the hood, the AutoRefresh control uses JavaScript to create a timer in the browser. When a timer tick occurs, a client callback request is sent to the server to get the updated images of controls present in the DefaultRefreshItems collection.  So what you need to do is the following: 
  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 your Gauge control (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, update a switch control, etc. In your case, you will update the Gauge control. 
  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 gauge control is being updated.
As a side note for when using ASP.NET, you need to use the UpdatePanel and ScriptManager in conjunction with the Timer control to get partial page updates. Basically you would place our NI controls inside the UpdatePanel control and enforce that only these controls would be updated and not the entire page. But again, currently with 8.1.2 and earlier, there are issues with using our controls with UpdatePanel and that's why its not supported yet. However, again, we will be fixing these problems in and upcoming release of Measurement Studio.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 2 of 2
(3,887 Views)