views:

64

answers:

3

I've been tasked with updating our contact and feedback forms for the entire site. Not quite sure how many forms are out there, but at least 20 and growing. I know that once this is in place it will be there for a while. Also, the person that will be responsible for adding new forms doesn't have much code experience so I'm trying to make it as easy as possible for them to create new forms.

My goal is to create a base class that allows the person to

  1. call a generic form
  2. add variables that will add any preset field to customize the form
  3. add some simple values such as who should be emailed and what's the name of the form for marketing purposes.

The database table has already been created with all the possible values that the form could have.

This is my first real project with ASP.NET but not my first project. I've used PHP Zend Framework for a few years and a lot of classic ASP before that.

Any pointers are greatly appreciated. I know I'm biting off a lot with my first ASP.NET project!

A: 

Your main Form settings (apart from actual fields displayed) could have properties like:

BrowserTitle

OnScreenTitle

EmailAddresses (eg comma delimited)

Description (above form fields)

Thankyou/Confirmation Message (after send)

SaveToDatabase flag in case some forms dont need to be saved (if you're keeping a DB copy)

Adding some kind of CAPTCHA (here is a good exmaple of a non-image implementation: http://stackoverflow.com/questions/8472/practical-non-image-based-captcha-approaches

Mark Redman
+2  A: 

Make a user control that handles the form fields for the feedback form, so you can reuse it on different pages.

To configure the control you can add public properties in the control class, like for example:

public string SendFeedbackTo { get; set; }
public bool ShowCaptcha { get; set; }

Then you can set those properties from the tag including the user control:

<uc1:FeedbackForm runat="server" SendFeedbackTo="[email protected]" ShowCaptcha="true" />

You can now user the property values in the event handlers in the user control.

Guffa
agreed, you could also create a property with the Type of your Form object: public EnquiryForm FormSettings { get; set; } used by your control.
Mark Redman
A: 

Investigate ASP.NET MVC to simplify the development and maintenance of your forms. They will be easier to understand and comprehend and testing them will be ... well, more trivial than regular ASP.NET

You should also think about using a simple YAML or XML file to describe the forms for novice users and parse that description instead of having too complex logic embedded into your own code.

See for instance Martin's Fowlers WIP on DSL - the example with the state machine

jhaukur