views:

649

answers:

3

I haven't started writing any code for this program, but here's what I need to do in C#/ASP.NET, both of which I'm just starting to learn.

I have a DIV on a page that I want to update with information from an MS SQL Server every five seconds.

  1. Would it be better to create my countdown timer on the JavaScript or C# side?

  2. Would UpdatePanel or creating a Page Method be more efficient for updating the DIV with the database information?

Load times are a serious issue for this application, so the lighter and faster the solution, the better.

A: 

If you decide to use a web service, use WCF instead. ASMX is now considered legacy technology by Microsoft.


For skeptics, from "XML Web Services Created Using ASP.NET and XML Web Service Clients":

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation (WCF).

John Saunders
@Downvoter: see http://msdn.microsoft.com/en-us/library/bb552872.aspx.
John Saunders
@New Downvoter: cat got your tongue? Say what the problem is, and maybe it can be corrected. Say nothing, and nothing will change.
John Saunders
+2  A: 

1) You'll have to create the countdown timer on the client in javascript since the client is disconnected from your server-side code except when it explicitly sends requests to it.

2) UpdatePanel will be less efficient, because it posts all of your page's form values (including any ViewState or EventValidation material), when all you might need to pass to the server is a few bytes (for an id, for example). However, this difference in efficiency may not be significant if your query times are high (or the cost of transporting/rendering the data is high).

Jeff Sternal
+1  A: 

The UpdatePanel will also use the timer on client side to refresh periodically. So it is better to use some efficient WebMethod rather than sending and retrieving whole form values using UpdatePanel. For more information regarding pros and cons of UpdatePanel and WebMethods you should visit Dave's website (http://www.encosia.com)

TheVillageIdiot