Jump to Main Content

Create a ASP.NET Contact Form

<%@ Page Language="C#"  AutoEventWireup="true"  CodeFile="contact.aspx.cs"  Inherits="contact"  %>
<!DOCTYPE html PUBLIC  "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1"  runat="server">
<h3>My Contact Form</h3>
<table id="contact"  cellspacing="0">
<tr>
<td>First Name:</td>
<td></td>
</tr>
<tr>
<td>Last Name:</td>
<td></td>
</tr>
<tr>
<td>Email:</td>
<td></td>
</tr>
<tr>
<td>Comments:</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>

As you can see from the example above, we’re dealing with an ordinary table with an ID that we can use for controlling the presentational aspect of our page, that is, a style sheet. However, for the purposes of this article, we’ll focus on the ASP.NET environment in relation to the form.

Client-server architecture demystified

In the web environment, everything is initiated by using protocols, requests for services or a combination of both. Specifically, when working with server-side technologies on the web developers work in client-server architectures. That is, a client such as a local computer requests through an HTTP protocol that a file be sent to it from a server. In response, a server receives the request, accepts it, and finds the file and returns the file to the client.

In some website environments, the only responsibility the server has is accepting the request, and delivering the file to the client. In other website environments, when dynamic pages exist, such as pages that end in ASP, ASPX, the server accepts the request, notices the page has an ASP extension, and as a result, knows that it needs to read, interpret and parse any server-side code before sending the file back to the client with the parsed HTML included. For a little added clarity, the illustration below clarifies the process.

Client side illustration

At this point, you may be wondering how the server knows what to do with these special files? It all boils down to Internet Services Application Program Interface (ISAPI). Every web server has the ability for files to interface with it, specifically by installing dynamic link libraries (DLL) that contains code functions that instruct the web server to interpret the request, and if the file has certain extensions, then parse the server-side code before sending the result back to the browser.

We'll continue by understanding web controls next.

top of page