Overview Support Download Purchase

Contact Form Example

The easiest way to get familiar with the TurnObjects system is to look at an example website. The contact form will collect basic information and a comment. The ContactForm project is located in the Examples folder. All further references to files in this example are assuming the ContactForm project. See the Getting Started page for more information.

Part 1 (Setup)

In this example:

  1. Create a Microsoft database and set the ConnectionString of the web.config to reference the new database.
  2. Load the solution into VisualStudio 2005.
  3. Run the application and look at the database modifications and assembly creation done by the system.

Create a Microsoft Database

To run the example you will need to create a Microsoft SQL database to store the contact information. The ConnectionString key in the web.config file will need to be modified to point to the new database. The connection string will be similar to the following:

Copy 

Set the TurnObjects Path

The TurnObjects system must know where it's working path is. The TurnObjects folder contains all the configuration information for the environment. Point the TurnObjectsPath key in the web.config file to the absolute path for the TurnObjects folder in the ContactForm example. If the ContactForm example is located on the C drive it may look something like the following:

Copy 

Running From VisualStudio 2005

Using VisualStudio 2005

Open up the TurnObjects solution file. Make the ContactForm the startup project and Default.aspx as the start page. Pressing F5 will launch the site.

Run the Application

The first thing the system will automatically do is make sure the assembly for the contact form system is compiled and database modifications are complete. The system does this by looking at the XML in the TurnObjects folder that describes the contact system.

You should now see the contact form interface and you can start adding new records. Looking at the database you will see that the database tables have been created by the system. You can also look at the Bin folder under the TurnObjects folder and see the assembly created for the contact objects.

Contact Form Interface

Part 2 (Modifying the System)

In this example:

  1. Examine the TurnObjects/Config/Live/ContactForm.xml configuration file and add a new email property.
  2. Tweak the display of contact records by modifying the properties of the TurnObject grid control.

Add a Property

To respond to users who have filled out the form you will need a way to contact to them. In this step we will add an email property to the contact form. To do this we will need to edit the ContactForm.xml file.

There are 3 major parts of the TurnObjects system configuration file: the system, schema, and schema property configurations. To modify the contact form we will want to add a new TurnProperty to the ContactFormEntry schema. Find the ContactFormEntry schema and add the following property after the LastName property. You can leave the application running while changing the configuration file.

Copy 

You also want the system to rebuild itself which means you need to set the CompileStatus in the configuration file to Pending. The compile status is located at the begining of the configuration file, usually around line 7. The CompileStatus will also show if the system has been successfully built or if it failed the last build.

The system configuration is held in ASP.NET cache and is dependent on the configuration file. Once this file is changed the TurnObjects will read the configuration file again. In this example, the change you made will require TurnObjects to look at the file again and adjust to your change.

If you refresh the web page you will notice the new email column has been added to the form. If you look in the TurnObjects Bin you will see the newly created assembly.

Modify the Entry View

The Entries.aspx page has a grid that shows all the contact forms that have been submitted. The grid control has many options that effect the operation of the grid. You can easily see the available options by looking at the grid control in design view or looking at it's properties in the aspx page. For example, if you wanted to enable a user to edit a contact form you would set the EnableEdit on the grid control to true. This would bring up the edit form for that contact when the user selects edit on the specified row.

Contact Form Interface

Part 3 (Email Notification)

You can tell the form to send a notification to a specific email address when a form gets submitted by setting the EmailNotification property to the required address. Add the following code (using a valid email address) to the ContactForm control in the Default.aspx page.

Copy 

Part 4 (Error Logging)

TurnObjects has built-in methods for logging errors to email. Use the following steps to add error logging to an application:

  • Set the ErrorEmailRecipients key in the web.config file to the email addresses errors are sent to.
  • Set the SmtpHost key to a valid SMTP server.
  • Set DefaultEmailFrom to an email address that the errors will come from.
  • The following code will need to be added to the Application_Error method in the Global.asax file.
Copy 

© 2008 TurnObjects All rights reserved.  Legal  |  Privacy