Is there any analog to Django forms (http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs) in ASP.NET MVC 2?
Is there any analog to Django forms ( http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs ) in ASP.NET MVC 2?
Share
I have listed out the “main topics” listed on the link you supplied…
In ASP.NET MVC you can use Html.EditorFor(Model) to auto-generate an entire form. You can add attributes to the model for any data items that you don’t want to scaffold.
This will generate an entire form with fields for each property.
Or you can use it on individual properties
or you can tell it what element you want
There are lots of ways to validate the data in ASP.NET MVC. You can add attributes to make items on the model mandatory, or to ensure their value is within a range, etc. In MVC 3, you will also be able to implement an “IValidatable” interface, which will add a “Validate()” method to your object that you can add your own custom rules to.
This is MVC out of the box, you should post back to the same page. It will automatically add CSS classes to the items that fail validation and will populate and validation place holders / validation summary.
Again, this is out-of-the-box stuff. If you post a form to an action, MVC will get the data into your model.