You cannot call server code 'Directly from client code. Which is because, by design, the server side code is executed on the server side and client code on the client. However, there are some workarounds. to call serveride code from javascript, you will need to use AJAX, and the easiest way out is to use ASP.NET AJAX Extensions.
Mark this link
" " PageMethods ASP.NET AJAX