Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


The Future of ASP

December 4, 2000

ASP.NET

ASP.NET is probably one of the most exciting things about .NET from a developer's perspective. ASP has been totally redone from the ground up. ASP.NET files will end with the .aspx extension (that is mainly so your existing .asp pages can still work fine). ASP.NET provides a number of great things, including improved browser compatibility with HTML server-side controls, easier configuration and application deployment, cleaner code and ease of use. In the following paragraphs we will take a look at some sample ASP.NET code.

HTML Server-Side Controls

ASP.NET has taken great strides to make compatibility issues a thing of the past. Every seasoned developer knows the nightmare that is making sure your page works on every browser for every platform. Most of us want to pretend these problems do not exist, but we all know they do. The solutions thus far have been either A) to build sites that dynamically detect a user's browsers and output a page appropriately or B) to build multiple versions of the same site. Frankly, both are obnoxious, though solution A is a much more desirable solution - it is just harder to get to work. Previously you would use the browser capabilities component, but if it isn't up to date, you can forget good results.

ASP.NET brings to the table some Server-Side Controls that will save you coding time and create cross-browser compatible code. What does it mean to have a server-side control? Actually, not much, other then the fact that the code has HTML elements that run on the server rather then being rendered client side. In other words, let's say you have a form tag, like the following: <form name="myform" action="somepage.aspx" method="post">. Now, anything that occurs with that form when the page is visited is a client side operation. However, add runat=server to the tag like so: <form name="myform" action="somepage.aspx" method="post" runat="Server"> and suddenly the form tag is a server control. Now, when the page is visited the server handles the tag rather then the client - which only deals with the visual display. No doubt, that makes next to no sense, so let's take a look at a practical application - saving state.

If you have ever used ASP for form handling, you will find relief in server-side controls. This is a sample of today's form handling with ASP - specifically saving state, or making sure that form fields retain their values if the user makes a mistake or if there is an error.

<%
if (Len(Request.Form("fname")) > 0) 
	OR (Len(Request.Form("lname")) > 0) then
    Dim fname, lname
    fname = Request.Form("First_Name")
    lname = Request.Form("Last_Name")
    ConfirmMsg = "Your name is: " & fname & " " & lname
end if
%>
<html>
<head>
    <title>ASP Form Sample</title>
</head>
<body>
    <% if ConfirmMsg <> "" then %>
        <h2><%= ConfirmMsg %></h2>
    <% end if %>
    <form action="thispage.asp" method="post" name="Input_Form">
      First Name:
      <input type="text" name="fname">
      <br>
      Last Name:
      <input type="text" name="lname">
      <br>
      <input type="submit" value="Submit Form">
      </form>
</body>
</html>

NOTE: the if statement: "if (Len(Request.Form("fname")) > 0) OR (Len(Request.Form("lname")) > 0) then" was broken for display purposes. In use it should be placed on one line.

Now, that is not so bad, but imagine if you had an employment application online with many more fields, writing out all that code becomes painstakingly boring as you well know.

Server-side controls put an end to that, completely. Let's take a look.

What is .NET?
The .NET Revolution
A Server With Memory


Up to => Home / Authoring / ASP / NetRev




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers