(Tutorial) Learn ASP.NET 2.0 - A "From the Ground Up" Tutorial (Part-3)

Tutorial : Learn ASP.NET 2.0 - A "From the Ground Up" Tutorial (Part -3)

Inline coding: "Classic" ASP

The next step up the ladder toward ASP.NET 2.0 is sometimes called inline coding and represents the kind of coding that was done with "old" or "Classic" ASP. To illustrate this type of coding, let's do approximately the same application using inline code. (By the way, all of these examples were executed in VWD.)

The idea here is that the server interprets what is sometimes referred to as a render block that is embedded in the HTML and then sends HTML back to the browser. So let's change our code to inline code for a "Classic" ASP page:

<html>
   <head>
      <title>
         About VB Hello
      </title>
   </head>
<body>
   <h1><%= "Hello World from About Visual Basic" %></h1>
   <p><%="Inline code embedded in the HTML"%></p>
</body>
</html>

It works, but we have actually gone backwards.

What used to be a page that the client computer could create now requires a round-trip to the server and the only thing the server does is send the same text back again. This only makes sense if the server actually does something. To demonstrate the concept, I've added some VB code. It really only results in the same thing again, but it shows how the server executes inline code before sending it back.

<html>
   <head>
      <title>
         About VB Hello
      </title>
   </head>
<body>
   <%
      Dim TextArray(2) As String
         TextArray(0) = "Hello World from "
         TextArray(1) = "About Visual Basic"
      TextArray(2) = _
         "Inline code involving some VB code."
   %>
   <h1><%=TextArray(0) & TextArray(1)%></h1>
   <p><%=TextArray(2)%></p> </body>
</html>

It's worth checking out the actual HTML sent back to the browser by selecting "View Source" in your browser. In this last case, for example, all of the inline code above was converted to:

<h1>Hello World from About Visual Basic</h1>
<p>Inline code involving some VB code.</p>

"Classic" ASP, of course, involved much more than this. Our goal is to make sure you understand what's happening between the client and the server.

Google