0

I have an asp.net application with Ajax in which I'm using update panel for a grid view for refreshing. I want to show the message on browsing window saying "Refreshing in 30 seconds" (number vary for each second).

halfer
  • 19,824
  • 17
  • 99
  • 186
ASD
  • 1,441
  • 3
  • 28
  • 41

2 Answers2

0

Look at the asp:Timer Control inside an update panel.

Here

Blounty
  • 3,342
  • 22
  • 21
0

You can do this on the client in javascript with some good old fashioned DOM manipulation:

var count=30;
var interval=setInterval(function()
{
    var tn=document.createTextNode("Refreshing in "+count+"s"); 
    var targetElement=document.getElementById("someElemId");
    var replaceText=targetElement.childNodes[0];
    if(replaceText!=null)
    {
        targetElement.replaceChild(tn,replaceText);
    }
    else
    {
        targetElement.appendChild(tn);
    }
    if(count==0)
    {
        clearInterval(interval);
        window.location.reload(true); //or whatever you need to refresh
    }
    --count;

},1000);

You'll need some sort of element in the DOM with id "someElemId". Of course, setInterval isn't 100% accurate, but should be good enough.

spender
  • 117,338
  • 33
  • 229
  • 351