• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

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
0
decoleur
Asked:
decoleur
  • 6
  • 3
3 Solutions
 
DanielcmorrisCommented:
use an ajax script
0
 
DanielcmorrisCommented:
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 :)
0
 
decoleurAuthor Commented:
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?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DanielcmorrisCommented:
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.  
0
 
DanielcmorrisCommented:
ajax is client-side, so your user's browser does the work.

If you're using c# and asp, you're probably using ASP.net, which means you can just as easily use an "UpdatePane", which is pretty much the same thing, but might be faster for you.


Anyway,  if you don't want the page to reload every five minutes, you're going to need to use javascript.

If you want to do it "correctly", then  you'll need to use AJAX to call the server and get updated values.  However.... before ajax came around, I used an awful hack that worked great  :)


I'm not sure if it will work on every browser, but....  Use an iframe.

<body>
here is my nice page
<p>
it has some nice text
<p>
Here is a picture that will change every 5 minutes <iframe src="frm.asp" border=0 style="width:200px;height:200px">
<p>
And here is one that won't <img src=mypic.jpg>
</body>

then, your frm.asp page.... well, you can set the meta to refresh, or you can have a javascript that reloads it, or you can have a javascript timer that simply changes the name of the src of the iframe.


0
 
decoleurAuthor Commented:
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
0
 
DanielcmorrisCommented:
So, you first make your javascript so you can get the data from the webserver.

Say it's called, fuction getmypork(){}

then, you have a function that runs it every 5 seconds.

var int=self.setInterval("getmypork()",5000)

<html>
<head>
<script>
var int=self.setInterval("getmypork()",5000)
fuction getmypork(){ alert('getting pork prices and putting them in some field on the page');}
</script>
</head>
<body>

pork prices right now: <div id=myprice></div>

</body>
</html>
0
 
DanielcmorrisCommented:
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?"

0
 
decoleurAuthor Commented:
Thanks for the input, updatepanel and timer seems like the way to go.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now