Use AJAX. https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started This will allow you to call a designated server-side method from the client.
From the link above:
function makeRequest(url) {
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!httpRequest) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
httpRequest.onreadystatechange = alertContents;
httpRequest.open('GET', url);
httpRequest.send();
}
function alertContents() {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
alert(httpRequest.responseText);
} else {
alert('There was a problem with the request.');
}
}
}
})();
You'll have to decorate your server-side method with the [WebMethod] attribute and declare it as public and static. http://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.90).aspx
From MSDN:
[System.Web.Services.WebMethod(EnableSession=true)]
public int GetNumberOfConversions()
{
return (int) Session["Conversions"];
}
It's that easy.
I have to question calling a method from client to server every second, however. You can handle that date business in JavaScript alone. Making a round-trip is not going to work out well for you, I'm betting.