The first thing we can do, once we have our project and ASPX page open in Visual Studio.NET, is to right-click the project in Solution Explorer, and then choose Add New Item.. AJAX Client Library. This will be our JavaScript Client Library, were we can place all of our functions to use on the page. For this example, though, we shall create just one.
Let’s go ahead and add a simple function:

The comment on this first line is inserted automatically by VS. It allows IntelliSense to be shown for the microsoft AJAX Library.

IN this function we are simply displaying an alert to the user that they clicked the button. Next we need to add a ScriptManager to the page to manage our AJAX calls, and also reference our Client Library. We do this by adding it between the Script tags like so:

To implement this button click, we insert script tags in the HEAD section of the HTML on our ASPX page:

Here we will place the function that will be assigned to our button click, and will reference the function we created in our Library. It should look something like this:

This very simple function is calling the function in our Client Library, and will display the alert box when executed. Now we need to create a button to execute this. Go back to below our ScriptManager, and add a button:

We use the OnClientClick attribute to call the function in the HEAD of our ASPX document, which in turn calls the function in our Library, thus displaying an alert.
Download Source Files