ASP.NET
  Home arrow ASP.NET arrow Page 4 - ASP.NET and the .NET Framework
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

ASP.NET and the .NET Framework
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 38
    2005-03-16

    Table of Contents:
  • ASP.NET and the .NET Framework
  • ASP.NET
  • Visual Studio .NET
  • The ASP Version
  • Hello World Using Visual Studio .NET
  • Add two more HTML labels

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    ASP.NET and the .NET Framework - The ASP Version


    (Page 4 of 6 )

    ASP allows the programmer to intersperse scripting code snippets within the HTML code. This scripting code can be written in a scripting language such as JavaScript or VBScript. Adding embedded script to your sample web page allows you to insert dynamic content. Modify the previous code listing, converting it to ASP, by changing the filename extension to .asp and adding VBScript to display the current time, as shown in Example 1-2. The output is shown in Figure 1-3.

    Example 1-2. Code listing for HelloWorld1.asp

    <% =Now%> <html>
       <body>
         <h1>Hello World</h1>
         <br/>
         <h2>The date and time is <% =Now%>.</h2>
     </body>
    </html>

    It may not look like much, but this represents a vast improvement over static HTML. ASP allows you to create web sites full of rich and dynamic content. The scripting allows for queries, reads and writes against databases, implementation of programming logic, control of the appearance of web pages in response to user actions or returned data, and a host of other features.


    Figure 1-3.  Output from Example 1-2

    Hello World the ASP.NET Way

    You will complete this evolutionary journey by changing your Hello World web page from ASP to ASP.NET. A key difference in ASP.NET is that you no longer use interpreted languages, but instead use compiled languages. Typically, ASP.NET applications are built using either C# or VB.NET. In either case, the performance will be a great improvement over script.

    A significant theme of this book is that the choice between C# and VB.NET is purely syntactic. You can express any ASP.NET programming idea in either language. We suggest you write in whichever language you’re more comfortable with. The transition from VBScript to VB.NET may be slightly easier than to C#, but much of the Microsoft and third-party documentation is in C#. In this book we will show most examples in both languages, though we confess to a slight preference for C# because it is a bit more terse.

    For a full exploration of VB.NET, see Programming Visual Basic .NET, Second Edition,by Jesse Liberty (O’Reilly),and for C#,see Programming C#, Third Edition by Jesse Liberty (O’Reilly).

    Example 1-3 shows vbHelloWorld1.aspx in VB.NET, and Example 1-4 shows the same program in C#.

    Example 1-3. Code listing for vbHelloWorld1.aspx

    <%@ PAGE language="VB" %>

    <%@ Page Language="VB" %>
    <html>
       <body>
         <h1>Hello World</h1>
         <h1>ASP.NET Style</h1>
         <h2>Using VB .NET</h2>
         <br/>
         <h2>The date and time is <% =DateTime.Now( ) %>.</h2>
       </body>
    </html>

    Example 1-4. Code listing for csHelloWorld1.aspx

    <%@ PAGE language="C#" %>

    <%@ Page Language="C#" %>
    <html>
       <body>
         <h1>Hello World</h1>
         <h1>ASP.NET Style</h1>
         <h2>Using C#</h2>
         <br/>
         <h2>The date and time is <% =DateTime.Now.ToString( )
                  %>.</h2>
       </body>
    </html>

    Note that the changes required to convert the ASP page to ASP.NET are minimal:

    1. Rename the file, changing the extension from .asp to .aspx.

    2. Add a first line to the code,called a page directive,which tells the compiler which language to use for all in-line code. Page directives can also be used to pass a variety of configuration settings to the compiler and will be discussed in more detail later.

    3. Change the script code to code written in the desired language.

    The output from these changes is shown in Figure 1-4.


    The ASP.NET version uses compiled code (either C# or VB.NET),which gives it a performance advantage. That advantage is meaningless in this simple example but can be very significant with larger and more complex programs.


    Figure 1-4.  Output from Example 1-3

    More ASP.NET Articles
    More By O'Reilly Media


       · Good Article for beginnerHi This good article for asp.net beginner The .NET...
     

    Buy this book now. This article is excerpted from Programming ASP.NET by Jesse Liberty and Dan Hurwitz (O'Reilly, 2003; ISBN 0596004877). Check it out at your favorite bookstore today. Buy this book now.

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT