如何使用asp.net c#自动刷新HTML页面 [英] How to refresh HTML page automatically using asp.net c#

查看:420
本文介绍了如何使用asp.net c#自动刷新HTML页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net c#创建一个聊天应用程序,其中我已经在HTML文件中编写了所有聊天文本,我不想以特定的时间间隔自动刷新这个html页面,那么c#是什么函数/代码

Hi,I am creating a chat application using asp.net c#,In which I have written all text of the chat in HTML file and I wan't to refresh this html page autometically with specific time interval,So what is c# function/code for this

推荐答案

问候,



我想,您可以使用setInterval() 。例如:



Greetings,

Hi i think , you can use setInterval(). For Ex:

<script type="text/javascript" language="javascript">

    var autoload = setInterval(function () {


(#divauto)。load(.....)
},10000);

< / script >

< body >

< div id = divauto > 此处的动态内容< / div >
< < span class =code-leadattribute> / body >
("#divauto").load(.....) }, 10000); </script> <body> <div id="divauto"> Your dynamic content here </div> </body>









问候

Dominic





Regards
Dominic


没有解决方案,你不能刷新一个html页面机智h C#。

C#在服务器上运行,而不是在客户端浏览器上运行。

您必须使用javascript在浏览器中刷新页面。



您可以使用
There is no solution to this, you cannot refresh a html page with C#.
C# runs on server, not on client browsers.
You have to use javascript to refresh page in browser.

You can do it using
window.setTimeout(function(){location.reload();},1000);





重新加载整个页面可能很重。

您可能更好地使用AJAX。

google ASP.NET AJAX教程,你可能会想出一些适合你的东西。

updatepanel很受欢迎。



Reloading the whole page can be heavy.
You might be better of using AJAX.
google "ASP.NET AJAX Tutorials" and you might come up with something that suits you.
The updatepanel is quite popular.


这篇关于如何使用asp.net c#自动刷新HTML页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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