tags:

views:

272

answers:

3

Hi guys,

I have to build a site like an auction-site:

I Have a detail page from items where a countdown should run down.

In this page nearly every second a update must be possible without a postback for the user:

  • coundown must be reset
  • money of aucton must be updated
  • gridView with last bidders must be updated

What kind of timer should I use for the countdown? How can I update every second from DB? ( Ajax? ) How can I update the values / gridView?

+5  A: 

You can use an UpdatePanel with Ajax.

However, given the nature of "Internet weather," one second per update is pretty aggressive for that approach.

You might instead consider using Silverlight. You would have much more control that way, and could minimize the amount of data that needs to go over the wire. In fact, you could use long polling with raw TCP connections, to further increase scalability.

RickNZ
The site around this detail site is completly in ASP.Net, can I use for a single Site Silverlight?What is if the database update get's empty, for example I will structure that, if no update is in it, there are no data to load.
Kovu
Yes, you can use Silverlight for a single site, or a single page, or part of a single page. Silverlight apps don't even require a UI if you don't want one.With a raw TCP connection and long polling, the server-side part of the call could simply pend if the DB was empty -- or return a "try later" error, or whatever. Another approach would be to use a Silverlight control with no UI, and the long-polling calls as a form of notification that would inform your Ajax code that something has changed, and that it's time for an update.
RickNZ
Okay, thank you. So let a JavaScript timer countdown and a silverlight let do the query and an updatepanel to the updates, right? DO you have examples for silverlight and updatepanel methods?
Kovu
I would do the timer or long polling from Silverlight, to keep as much type-safe / compiled code as possible. From Silverlight, you can then call into JavaScript if/when needed. I don't have examples for this particular scenario, but I do have some in my book for general Silverlight, including how to interact with JavaScript and cookies: Ultra-Fast ASP.NET (Apress).
RickNZ
A: 

For the countdown, you can use the JavaScript timing events. To access the database, if you don't want postback then you indeed need to access the data service by using Ajax. To make things easier, I recommend that you take a look at any Javascript libary such as JQuery.

Konamiman
A: 

For the timer I would use Threading.Timer so this can count down uninterrupted in a separate thread. You could also use a TimerCallback delegate which would do the database processing. However, I would be wary about trying to query the database at such a rate.

I would advise you look at using Ajax Update Panel for updating the countdown section of the page alone so you don't have to refresh the entire page.

James
+1 for Threading timer. I'd be wary of what is in the update panel as it sends back a lot of unneeded html. Returning json would be less busy.
John Nolan
Than yout but isn't the javascript timer performence less as a new thread? For example if you have 500 users visiting the site, then 500 Threads will be started?
Kovu