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.
我还没有开始为这个程序编写任何代码,但这是我在C#/ ASP.NET中需要做的事情,我刚才开始学习这两个代码。
I have a DIV on a page that I want to update with information from an MS SQL Server every five seconds.
我在页面上有一个DIV,我想每隔五秒钟从MS SQL Server更新一次信息。
-
Would it be better to create my countdown timer on the JavaScript or C# side?
在JavaScript或C#端创建倒数计时器会更好吗?
-
Would UpdatePanel or creating a Page Method be more efficient for updating the DIV with the database information?
UpdatePanel或创建页面方法是否更有效地使用数据库信息更新DIV?
Load times are a serious issue for this application, so the lighter and faster the solution, the better.
加载时间是此应用程序的一个严重问题,因此解决方案越轻越快越好。
3 个解决方案
#1
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.
1)您必须在javascript中在客户端上创建倒数计时器,因为客户端与服务器端代码断开连接,除非它明确向其发送请求。
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).
2)UpdatePanel的效率会降低,因为它会发布所有页面的表单值(包括任何ViewState或EventValidation材质),而当您需要传递给服务器的所有内容都是几个字节时(例如,对于id)。但是,如果您的查询时间很长(或者传输/渲染数据的成本很高),这种效率差异可能不会很大。
#2
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)
UpdatePanel还将使用客户端的计时器定期刷新。因此,最好使用一些有效的WebMethod,而不是使用UpdatePanel发送和检索整个表单值。有关UpdatePanel和WebMethods的优缺点的更多信息,请访问Dave的网站(http://www.encosia.com)
#3
If you decide to use a web service, use WCF instead. ASMX is now considered legacy technology by Microsoft.
如果您决定使用Web服务,请改用WCF。 ASMX现在被认为是微软的传统技术。
For skeptics, from "XML Web Services Created Using ASP.NET and XML Web Service Clients":
对于怀疑论者,来自“使用ASP.NET和XML Web服务客户端创建的XML Web服务”:
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).
本主题特定于遗留技术。现在应使用Windows Communication Foundation(WCF)创建XML Web服务和XML Web服务客户端。
#1
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.
1)您必须在javascript中在客户端上创建倒数计时器,因为客户端与服务器端代码断开连接,除非它明确向其发送请求。
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).
2)UpdatePanel的效率会降低,因为它会发布所有页面的表单值(包括任何ViewState或EventValidation材质),而当您需要传递给服务器的所有内容都是几个字节时(例如,对于id)。但是,如果您的查询时间很长(或者传输/渲染数据的成本很高),这种效率差异可能不会很大。
#2
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)
UpdatePanel还将使用客户端的计时器定期刷新。因此,最好使用一些有效的WebMethod,而不是使用UpdatePanel发送和检索整个表单值。有关UpdatePanel和WebMethods的优缺点的更多信息,请访问Dave的网站(http://www.encosia.com)
#3
If you decide to use a web service, use WCF instead. ASMX is now considered legacy technology by Microsoft.
如果您决定使用Web服务,请改用WCF。 ASMX现在被认为是微软的传统技术。
For skeptics, from "XML Web Services Created Using ASP.NET and XML Web Service Clients":
对于怀疑论者,来自“使用ASP.NET和XML Web服务客户端创建的XML Web服务”:
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).
本主题特定于遗留技术。现在应使用Windows Communication Foundation(WCF)创建XML Web服务和XML Web服务客户端。