问题描述
我想听听您关于使用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,
推荐答案
<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();
}
这篇关于自动刷新网页或部分网页的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!