Using Ajax to Post an HTML Form

The previous examples used the HTTP GET method, but we can as easily post data with Ajax, too. This is most commonly done to submit form data. The principal benefit of posting data with Ajax is that the page doesn't have to be reloaded, providing a smoother experience for the user. In this section, we'll start by building a regular ASP.NET form-based web page and then extend it to work with Ajax in different ways. This example will also demonstrate that Ajax isn't all about web services (although, in fairness, it often is, so I'll finish this section by showing you how to post to a web service).

Creating the Web Page

We will start by creating a simple form-based ASP.NET web page, called Calculator.aspx. This page ...

Get Applied ASP.NET 4 in Context now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.