Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 6-Feb-14 23:38pm
v3

Greetings,

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

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

    var autoload = setInterval(function () {
        $("#divauto").load(.....)
    }, 10000);

</script>

<body>

 <div id="divauto"> Your dynamic content here </div>
</body>




Regards
Dominic
 
Share this answer
 
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
JavaScript
window.setTimeout(function(){location.reload();},1000);


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.
 
Share this answer
 
Hi,

Please check this
stackoverflow
code.google.com
 
Share this answer
 
Hi,
Please check this,


[^]
 
Share this answer
 
Comments
SVT02 7-Feb-14 5:31am    
But actually i don't want refresh .aspx page ,I want refresh only html page using asp.net c#
Rockstar_ 7-Feb-14 5:42am    
i think u want to refresh only a part of the page
if yes, using UpdatePanel u can do this...
Use UpdatePanel and set Updatemode conditional...
 
Share this answer
 
Comments
itsathere 21-May-15 1:55am    
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function () {
var interval = setInterval("ReloadPage()", 60000);
});

function ReloadPage() {
location.reload();
}
</script>

In above script 60000 is time interval in miliseconds.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900