Calling a c# method in java script in specfic interval of time

Iam creating a User Control .ascx & .ascx.cs in which i need to call a method "CompareTime()" in an interval of time.Below is the code but its not calling the c# method
var rTimer;
var sds ;
function TimeTick()
      sds =  new Date();
      rTimer = setTimeout('TimeTick()', 1000);
can any one help me
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You cannot interrupt server side processing to wait for client side events.

Everything runs on the server.
Then everything runs on the client.

(Well, that's a little simplistic, the page could still be being generated on the server while the client side stuff is being processed by the browser).

First the browser requests something.
Then the server sends back an entire resource as the response.

You can't have the browser request something. Get half a response back. Send more information back to the server. Then get the other half of the response back.

The way to approach this problem would be to have your ASP output a JavaScript variable with the server time and then do all the rest of the processing on the client.

Another option is to use XMLHttpRequest to send back another request to the server without loading a new page, and then to process the data it returns.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.