A bit of background:
I'm building an MVC app to store golf course data and have created a Create view page for the courses. This contains a partial view of a scorecard that I am going to use for other things such as recording results etc. I've currently built the scorecard so it fires off jQuery triggers when it is edited. From which the course create has jQuery code bound to these events and populates hidden form inputs for each of the 18 holes.
Question:
I was wondering if I need to have a mass of hidden form inputs on my create page to store the fired values or if I can have a list in my view model that I can update somehow.
Any more elegant solutions than what I have at the moment would be helpful.
You could create a custom class like ScorecardFormViewModel and include the items you need as properties and have your View inherit ScorecardFormViewModel
EDIT:
public class ScoreCardFormViewModel {
// Properties
public List<ParValues> { get; private set; }
public GolfCourse GolfCourse {get; private set;}
public ScoreCardFormViewModel(int golfCourseId)
{
GolfCourse = SomeMethodToGetGolfCourseFromModel(golfCourseId);
// Some way to populate ParValues
}
}
I just created a list of ParValues, maybe an over simplification, but you could put as many properties as you wanted here