1

In ASP.NET MVC one can create strongly typed Views but suppose if a view has already been made, so would it be possible to derive a model from it?

Like create model from view. A possible scenario would be: a designer makes a view (with forms) and then the developer would create a model from that form

3
  • 2
    I've never heard of this, but would be cool if possible. Though I have my doubts. Commented Feb 23, 2011 at 18:35
  • Even if you could create some kind of parser to generate a model class, how would you know what data types to assign to the properties?
    – 300 baud
    Commented Feb 23, 2011 at 18:40
  • @300 baud Since at the end of the day everything is serialized into a string for html output, perhaps the derive tool would just assume all properties to be a string? then after the tool runs the user could edit the data types themselves. Commented Feb 23, 2011 at 19:13

1 Answer 1

2

Possible? Yes.

You could certainly translate <input type="text" data-format="int" name="Price" /> into public int Price { get; set; }

Devil is in the details though.

2
  • Or if you only allow it for HTML5: <input type="number" name="rating" min="1" max="10" /> would translate to: [Range(1, 10)] public int Rating{get; set;} Commented Feb 24, 2011 at 13:31
  • Thank you guys. Are there any simple tutorials on this that i can refer to? Commented Feb 26, 2011 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.