Creating a ASP.NET Contact Form
When developing a website for business, personal or organizational use, having a reliable, secure and intuitive way of ascertaining information from your visitors in an effort to better meet their needs, creating and developing a contact form is essential. Creating a form allows website owners to ask for specific information from the visitor in an effort to respond back to them in a way that seems meaningful and useful. However, if precautions are not taken, creating these forms can lead to abuse, misuse and incorrect information getting back to the business, person or organization, and in most cases, leading to a mess of unsolicited electronic mail that wreaks havoc on email systems.
In this article, we will look at creating a ASP.NET contact form that will allow us to capture specific information that we need, validate form fields using client and server side languages to ensure that fields are not empty and then send the results to a specified recipient (s) that will allow them to respond to the visitor in depth when time and information permits. In order to do this, we need to download and install the .NET framework, install Internet Information Services (IIS), understand client-server architecture and its relation to web programming. If you would like to learn how to create such a form, as well as learning about these concepts in-depth please follow along with the article below.
If you would like to follow creating a web page’s step-by-step development or try your hand at creating one yourself, you will find the project zip link below helpful.
**Caveat: Due to the concern of spam emails regarding this tutorial, I haven't provided a live working example.
| Printable Version | |
| Word | |
| Download Project Files | |
| Zip | |
Requirements
In order for us to work effectively, we’ll create our form through Internet Information Services (IIS) on our local computer and then transfer the files to our remote host. There are a variety of reasons for taking this approach including: (1) some hosts have low remote connectivity timeouts which makes developing these types of forms difficult to accomplish remotely, (2) you have more flexibility debugging your code locally and (3) most hosts don’t allow direct access to their server from within an editor. As a result, we’ll need the following software installed on our computer:
- Windows XP Professional
- Internet Information Services (IIS)
- Microsoft.NET Framework (version 2.0 or 3.5 will work)
- Preferably Visual Web Developer express (free)
Pre Download Information
For the purposes of this article, it’s assumed you have Windows XP Professional installed. Continuing, let’s first download and install the .NET framework from Microsoft. If you’re wondering why we’re skipping Internet Information Services (IIS) at the moment, it’s because often times if you install IIS before installing the .NET framework, IIS will not install and configure properly some of its services correctly, including the association it has to the .NET framework, among others.
Download and Install .NET Framework
In order to download and install the .NET framework, open your preferred web browser and follow the web address below:
http://www.asp.net/downloads/essential/
From this page, you’ll see two download areas, one for the .NET framework and one for Visual Web Developer Express, choose the .NET framework. Once you click the link, you’ll be prompted to save the executable file to a location of your choice, once downloaded, double click the file and follow the steps.
Download and Install Visual Web Developer Express
In order to download Visual Web Developer Express, return to the web address provided above, click the download link, and once again, you’ll be prompted to save the executable file to a location of your choice, once downloaded, double click the file and follow the steps.
Installing Internet Information Services (IIS)
You may be wondering at this point, if we need to bother with installing Internet Information Services (IIS) since we already installed the .NET framework and Visual Web Developer. Even though we have the framework installed which gives us access to the classes, web controls and resources needed to create our form, when working with web applications we still need a web server that is capable of accepting our request from the client’s browser, parsing server side web controls, programmatic code and then sending the result back in html so that a web browser can understand and render the web page appropriately. More on the concept client-server architecture will be covered later in the article.
In order to install Internet Information Services (IIS), follow these steps:
- From your desktop, click Start : Settings : Control Panel
- In your Control Panel, double click Add or Remove Programs
- In this window, on the left side, left click Add/Remove Windows Components
- In the Windows Components Wizard, scroll down until you find Internet Information Services and check the box
- Left click Next
- At some point during the install process you’ll be prompted for your Windows XP CD which is where IIS resides
Once this is complete, close all windows, we’ll need to test and verify the ASP client was registered with IIS.
We'll continue with testing localhost, our web server next..