13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1: Introduction to <strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong> 9From Client Side to Server SideAs you saw in Figure 1-2, all that the web browser does is make requests to the server andreceive web pages in the form of HTML. The browser takes the HTML and constructs apage for viewing on your browser. For the most part, that’s what will continue to occurwhen you adopt <strong>ASP</strong>.<strong>NET</strong>. The main difference is that by writing and executing serversidecode, you can generate HTML that effectively handles dynamic states so that you canuse and reuse a given state. Figure 1-3 shows the general flow when an <strong>ASP</strong>X file on aMicrosoft server receives a call from the client.In looking for an example, we need look no further than the original example of theHTML page with the form. With a server-side program to catch the data that is sent tothe server, lots of processes on the server are possible. Suppose the user enters the name,Willie B. Goode. The server-side file can use the property name, username, to extract avalue. In this case, it would extract the name Willie B. Goode and do something with it. Itmight run a SQL script to store the name in a database, <strong>com</strong>pare it with a password, or itcould pass information about Willie B. Goode back to the browser in HTML.To get an idea of the differences and similarities between HTML and <strong>ASP</strong>.<strong>NET</strong>, wecan take the HTML form and add a calculated response from the server. In this nextexample, you will see two scripts. One is the <strong>ASP</strong>.<strong>NET</strong> script and the other is the C# codeusing a code behind file to serve as the event engine for the application. The form tagincludes a name and the coderunat="server"Data reference to <strong>ASP</strong>X file<strong>ASP</strong>X fileClientBrowserServer executescode; resultsconverted to HTMLand returned to clientReturns HTMLServerFigure 1-3 Server-side script

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

Saved successfully!

Ooh no, something went wrong!