(I'm new to MVC).
In my application I don't have a model in the sense of a class with properties. Oh no it's much simpler: my users basically fill in a bunch of string values for various keys setup elsewhere in the system (the keys are arbitrary and not known ahead of time, thus no pre-coded class)1.
My "model" thus is just:
Dictionary<string, string>
Pretty simple.
As I understand it model binding, html helpers, model state, validation summaries all rely on reflection of an arbitrary class' properties. But can they just use the key/values in my dictionary instead?
For example, can I have:
<label for="Name">Name:</label>
<%= Html.TextBox("Name") %>
<%= Html.ValidationMessage("Name", "*") %>
and:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Dictionary<string, string> valuesEntered)
{
// ...
}
and have MVC use the "Name"
key/value as found in my Dictionary<string, string>
"model" to do all its behind-the-scenes magic? (MVC 1.0 preferrably, but please shed some light if this is better addressed in 2.0 as I'd still like to know)?
1: sounds silly I'm sure. It's for a reporting app, where the "keys" are the report parameter names and the "values" are the values the report will run with.