JavaScript is a client side technology and would know nothing about what's there on the server until you do a postback.
There is a technology called AJAX which does exactly what you require. Quoting AJAX definition from
Wikipedia[
^]:
AJAX an acronym for Asynchronous JavaScript and XML is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data is usually retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not needed (JSON is often used instead), and the requests do not need to be asynchronous.
There are many examples for the same on the web. Search Google for "AJAX asp.net" or "jQuery AJAX" (post using jQuery is what lot of people are using these days) to get started.
Hope this helps!