2

In an upcoming project, we will be creating forms for citizen's to fill out to start the process of applying for the requested license or permit. As one can imagine, a form tends to change often. I would prefer to plan this into the application to avoid making changes on a yearly/monthly/"the big boss want's it yesterday" basis.

My searching has shown me some examples based on the object passed to the view, but those would require coding changes. Others use XML, but never seems to go through the entire process from creating the from to storing the inputted data into the database. It isn't that I need hand holding the entire way; it's that this is something completely different for me and I want some guidance to get me in the right direction. I am thinking along the lines of how these survey sites (like SurveyMonkey) create dynamic polls.

Is there any tools, utilities, tutorials, or books that may cover this quite well?

marcind
  • 52,944
  • 13
  • 125
  • 111
Mike Wills
  • 20,959
  • 28
  • 93
  • 149
  • 1
    have a look at this might be of your interested as its very similar to your question http://stackoverflow.com/questions/926934/dynamic-runtime-generated-forms-in-asp-net-mvc – Bulvak Jun 08 '11 at 18:49
  • Our projects are coming up quickly to do this. We are thinking about noSQL for this. I'll blog about it on my blog as we come to a complete solution. – Mike Wills Jan 27 '12 at 19:01

1 Answers1

1

I would imagine you would probably want to take advantage of Display / EditorTemplates. You would define an interface IQuestion or something, and then have a bunch of different form options that implement that interface. So your model would have a List<IQuestion>, and then for each question in the list, Html.EditorFor(item) or so.

Then some kind of standardized way of storing the answers into a table (perhaps a unique save / load method on IQuestion. That's my take anyways. You could define the questions via DB and then your models could have varying counts (and elements) in the List<IQuestion>. Just run a DB script (or some kind of admin page) and you could dynamically change the form displayed.

Tejs
  • 40,736
  • 10
  • 68
  • 86