I am trying to learn ASP.net MVC 2 and I have created the DB table, Model, View and Controller for a sample Bug Tracking System with just one table. I am also able to perform CRUD operations on the bug tracker. When I create a ‘New Bug’ the application asks me for Bug Name, Bug Id, Bug Description, Bug create date, Bug Due date.
My question is I don’t want to enter the Bug create date and Bug Due date every time. I want the Bug Create Date to be auto populated with the current date and time from the system. And the bug Due date to be auto populated with the value that is & days from the create date that is current date+ 7 days.
Should I do this in views? Do I need to do this using JavaScript or is there any other way?
I am trying to learn ASP.net MVC 2 and I have created the DB
Share
Assuming you have a strongly typed view, currently for create view you must be sending a new instance of the model from the controller.
If you set the date properties and send the model as shown below, your date fields should be populated in the view.