03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

350 x CHAPTER 10 <strong>ASP</strong>.<strong>NET</strong> AJAX<br />

library—while still present <strong>in</strong> <strong>ASP</strong>.<strong>NET</strong> <strong>4.5</strong>—is no longer the recommended solution. Instead, you’re<br />

encouraged to use jQuery, which is discussed <strong>in</strong> detail <strong>in</strong> the next chapter.<br />

The server-side part of Microsoft <strong>ASP</strong>.<strong>NET</strong> AJAX gives you a lot more than flicker-free postbacks.<br />

In addition to the controls that make flicker-free pages possible, Microsoft <strong>ASP</strong>.<strong>NET</strong> AJAX gives<br />

you a few more server controls to create rich, <strong>in</strong>teractive, <strong>and</strong> responsive user <strong>in</strong>terfaces.<br />

THE CORRECT SPELLING OF AJAX<br />

You’ll come across two different spell<strong>in</strong>gs of Ajax: us<strong>in</strong>g Pascal cas<strong>in</strong>g, or <strong>in</strong> all<br />

caps. I’ll use the term Ajax when referr<strong>in</strong>g to the general concept, <strong>and</strong> I’ll use <strong>ASP</strong><br />

.<strong>NET</strong> AJAX when specifically referr<strong>in</strong>g to Microsoft’s Ajax framework.<br />

By the end of the chapter, you should have a good underst<strong>and</strong><strong>in</strong>g of the various server controls that<br />

the <strong>ASP</strong>.<strong>NET</strong> AJAX Framework has to offer. You will also have a basic underst<strong>and</strong><strong>in</strong>g of creat<strong>in</strong>g<br />

WCF Services <strong>and</strong> page methods us<strong>in</strong>g <strong>ASP</strong>.<strong>NET</strong> <strong>and</strong> how you can call them from client-side<br />

JavaScript code.<br />

INTRODUCING AJAX<br />

In the first chapter of this book you learned how browsers <strong>in</strong>teract with the server. The browser makes<br />

a request for a page us<strong>in</strong>g GET or POST, as you’ve seen <strong>in</strong> Chapter 4 <strong>and</strong> Chapter 9. The server processes<br />

that page <strong>and</strong> sends back the result<strong>in</strong>g HTML. The browser then parses that HTML <strong>and</strong> renders the<br />

page to the user, optionally download<strong>in</strong>g any external resources like images, script files, <strong>and</strong> cascad<strong>in</strong>g<br />

style sheets (CSS). When a user <strong>in</strong>teracts with the page (for example, by click<strong>in</strong>g a button to submit a<br />

filled-<strong>in</strong> contact form) the page is posted back to the server, after which the entire page is loaded <strong>in</strong> the<br />

browser aga<strong>in</strong>. The left-h<strong>and</strong> side of Figure 10-1 shows a visual representation of this process.<br />

Traditional Page Process<strong>in</strong>g<br />

Ajax Page Process<strong>in</strong>g<br />

Web Server<br />

Traditional<br />

Request<br />

1 2<br />

Full Page<br />

Response<br />

Web Server<br />

Ajax<br />

Request<br />

1 2<br />

Partial<br />

Response<br />

Browser<br />

Browser<br />

FIGURE 10-1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!