Link to home
Start Free TrialLog in
Avatar of decoleur
decoleur

asked on

Auto refresh of a dynamically generated page in ASP that is tied to MS SQL

We are trying to build an app that lets a user select one of a series of real time reports using a drop down that refreshes the page to show a table with the real time values for that report. The challenge is that we are trying to make the results page refresh every 5 seconds and all attempts to do this cause the whole page to refresh without the selection made.

any suggestions would be appreciated, this was supposed to have been done yesterday.

thanks in advance,

-t
Avatar of Danielcmorris
Danielcmorris
Flag of United States of America image

use an ajax script
I use an included opensource javascript framework called prototype that has some nice shortcuts.

Right now I'm working on a new site: http://portfsa.org/tools/calculator.aspx

That page has a calculator on it.  When the user leaves a field, it actually sends a call to the server, gets the updated calculation and places the result in the subtotal box.  (not some javascript calculator script working client-side)

calls this script:
function morris_ajax_v_1_0(params,id) {

        //  var params = "test=1"
          var url = "/ajax/calculator.asp"  
        new Ajax.Request(url, {
          method: 'get',
          parameters: params,
          onSuccess: function(transport) {
           // var data = transport.responseText.evalJSON()
           // $('total_current_cash_needs').innerHTML =    data.total_current_cash_needs;
           
              setvals(transport.responseText, id)
            }
        });
      }

which returns simple JSON that is generated with asp using variables that are adjusted by the client in their database.

{'total_current_cash_needs':'$0.00', 'total_cash_for_monthly_income':'$0.00', 'total_cash_reserve_required':'$0.00', 'total_assets':'$0.00', 'total_life_insurance_needed':'$0.00', 'total_current_and_long_term_cash_needs':'$0.00' }



Feel free to rip out whatever you'd like if you're interested :)
Avatar of decoleur
decoleur

ASKER

can you please elaborate? we are using visual studio c# and asp, how would we incorporate ajax?
I am not adverse to it but do not know what is entailed.

Can you provide more info on this?
here is how you can trigger that update with a timer:

http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

There's a lot of other options.  
SOLUTION
Avatar of Danielcmorris
Danielcmorris
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Danielcmorris-

This is a nice interface but this is requiring the user to do something. Our user says they want to look at the pork futures page and then every five seconds we want to update the values for the different columns. Our problem is that the refreshing page is post selection. could you provide any pointers for that?

Thanks in Advance!

-t
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
http://www.asp.net/learn/ajax-videos/video-99.aspx works too.

It may be best to stick with PCableGuy's solution if you intend to have this project run by someone else.

Basically, don't do a bunch of custom code that some new employee might stumble on.  With the ajax toolkit, you can simply ask the new employee, "so, do you know how to use an updatepanel and timer?"

Thanks for the input, updatepanel and timer seems like the way to go.