You cannot call server-side code ‘directly’ from client-side code. However, there are some workarounds. To call server-side code from Javascript, you will need to use AJAX, and the easiest way out is to use the ASP.NET AJAX Extensions. In this article, we will be using PageMethods to call server-side functions using Javascript.