1. Home
  2. Computing & Technology
  3. Visual Basic

Learn ASP.NET 2.0 - A "From the Ground Up" Tutorial
Inline coding: "Classic" ASP

By Dan Mabbutt, About.com

Mar 26 2008

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.

Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Learn ASP.NET
  6. Learn ASP.NET 2.0 - A "From the Ground Up" Tutorial

©2009 About.com, a part of The New York Times Company.

All rights reserved.