0

Context: Building a web app using ASP.NET MVC 5 with EF 6.1.3 linked to an SQL Server database.

I have a pre-loaded form which I am trying to dynamically populate based on a drop down list (in this case it is car registrations). Ideally, upon selection an Ajax request is made which would return a model object which I could then link with the pre loaded form entries. The form entries are of type:

        @Html.LabelFor(m => m.VehicleInformation.PreviousOwners, new { @class = "col-md-3" })
        @Html.TextBoxFor(m => m.VehicleInformation.PreviousOwners, new { @class = "form-control", id = "PreviousOwners#" })
        @Html.ValidationMessageFor(m => m.VehicleInformation.PreviousOwners)

Is there an ASP.NET specific solution to this? I have explored the below two options, the Json solution is clunky for large forms and the PartialView method doesn't make use of the pre-rendered form:

1) Returning a Json object and jquerying data into the form;

2) Loading a partial view with the returned model object.

MJ_Wales
  • 873
  • 2
  • 8
  • 20
  • Hi, I am looking for similar solution as well? Have you found any yet? My scenario is that I can have 100 plus fields on a form and I need to display fields depending on who is logged in. The business/validation rules can be different for each user as well. – learner Jun 18 '18 at 15:44
  • @learner I opted for solution (1) and used jquery to populate the form. Although it is clunky it is easy to implement. – MJ_Wales Jul 11 '18 at 08:19

0 Answers0