自动刷新网页或部分网页的最佳方法 [英] Best way to auto refresh web page or part of it

查看:147
本文介绍了自动刷新网页或部分网页的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想听听您关于使用C#.NET保持网页自动刷新或部分刷新的最佳方法的一些意见和建议.这个想法是进行网络拍卖,并让投标人及时了解最新变化.我已经有了带有Update Panel和Timer tick事件的池解决方案,该事件以很小的间隔刷新网页并一直从数据库请求数据.这可能是最可靠的解决方案,但它可能会使服务器超载,并导致速度减慢,超时等.此外,我对诸如Comet之类的其他反向技术也了解甚少,但是我发现的示例仅在IE中有效.任何建议,示例或阅读资源都将有所帮助.
谢谢,

I would like to hear some of your opinion and suggestions about what is the best way to keep auto refreshing web page or part of it with C# .NET. The idea is to make web auction and keep the bidders posted about the latest changes. I already have pooling solution with Update Panel and Timer tick event that refreshes the web page on small interval and requests the data from database all the time. This may be the most reliable solution but it may overload the server and cause slowdowns, timeouts or etc. Also I''ve been reading little about other reverse techniques, like Comet, but the example I''ve found worked only at IE. Any suggestions, examples or resources to read will help.
Thanks,

推荐答案

下面的示例演示如何使用asp.net ajax每0.5秒刷新一次asp.net页面中的部分.
the following example shows how to refresh part in asp.net page every 0.5 second using asp.net ajax

<form id="form1" runat="server">
 <div>
 <asp:ScriptManager ID="sm1" runat="server" />
 <asp:UpdatePanel runat="server" ID="up1">
 <ContentTemplate>
 <asp:Label ID="currentTime" runat="server" /><br />
 <asp:Timer runat="server" ID="refreshTimer" Interval="500" Enabled="true"

         ontick="refreshTimer_Tick" />
 </ContentTemplate>
 <Triggers>
 <asp:AsyncPostBackTrigger ControlID="refreshTimer" EventName="Tick" />
 </Triggers>
 </asp:UpdatePanel>
 </div>
 </form>









protected void refreshTimer_Tick(object sender, EventArgs e)
      {
          currentTime.Text = DateTime.Now.ToLongTimeString();
      }


<>>>>>>>>
<>>>>>>>>>>


什么关于仅在发生更改而不是使用计时器时刷新?

也许您可以看看观察者模式? [ ^ ]

观察者模式(发布/订阅模式的子集)是一种软件设计模式,其中一个对象(称为主题)维护其从属者列表(称为观察者),并自动将状态变化通知他们,通常是通过调用其方法之一来实现的.它主要用于实现分布式事件处理系统."
What about refreshing only when a change has ocurred instead of using a timer?

Maybe you could take a look at the Observer Pattern? [^]

"The observer pattern (a subset of the publish/subscribe pattern) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems."


这篇关于自动刷新网页或部分网页的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆