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


A Server With Memory

December 4, 2000

Now, check this out! Look at the code below and now look at the source code from the browser in the screenshot just below the code. Is it not amazing how it automatically fills in the name and value attributes? Okay, maybe it is not amazing, but it is still really helpful. On a form with tons of fields you have just saved lots of time, decreased file size and improved code readability. So how does it work? Well, as I said before it is a server-side control, so rather then rendering and being processed by the client, form elements with the id's fname and lname are posted to the server and remembered. They are sent back to the browser in an HTML 3.2 compliant form (which means it will render well on most browsers) with all your fields filled in. Let's take a look at what is different about the code in this page.

<html>
    <head>
        <title>ASP Form Sample</title>
    </head>
    <body>
<%
if (Len(fname.value) > 0) OR (Len(lname.value) > 0) then
    Response.Write("Your name is: " & fname.value _
& " " & lname.value)
    end if
%>
        <form runat="server">
          First Name:
          <input type="text" id="fname" runat="server">
          <br>
          Last Name:
          <input type="text" id="lname" runat="server">
          <br>
          <input type="submit" value="Submit Form">
          </form>
    </body>
</html>
Rendered Source Code

First, notice how we remove the whole check at the top of the page for whether or not the form is submitted. Instead, we have a check in the middle of the page for the Len(fname.value) > 0 OR Len(lname.value) > 0. In other words, the page makes sure that fname or lname has a length of greater then nothing; however, how is this possible without using Request.Form? To put it simply, it is because of the manner in which .NET saves state and deals with server controls. As you will note, each server control has an id rather then a name. ASP.NET requires that these id's be unique, that way it can keep track of them! As you can tell from the resulting source code, the server uses these id's to assign the needed attribute names and values. Furthermore, it is now possible to reference each element by using just the ID you assigned. Wow!

Believe it or not, saving state is just the tip of the iceberg. With some simple coding of server-side controls; form-field validation, simple data binding and all sorts of other goodies! You can have custom pre-coded events run with server controls, and make even more dynamic and intelligent pages. If you have any experience with VB Forms, then ASP.NET will be a welcome change to you, because they introduce a similar concept coined Web Forms, which operate on advanced techniques of the one I showed you above. What is important to note is that none of it is very hard to do and all of it very useful.

The Future of ASP
The .NET Revolution
There is More!


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