James Culshaw
James Culshaw

Reputation: 1057

What is the best way to do this in ASP.NET MVC3?

I want to have a form which has a simple 2 step process:

(If a person on has one school assigned to them then skip straight to step 2)

Step 1 - Select a school from a drop-down list

Step 2 - Enter the required data from a data-entry form. Certain fields are disabled based on which school was selected.

I have had a look at the various methods for creating 'wizards' and at using partial Views. What is the best way to handle this? I was wondering if using AJAX is worthwhile considering or just having a two step process in the form.

James :-)

Upvotes: 0

Views: 86

Answers (1)

Adam Tuliper
Adam Tuliper

Reputation: 30152

You should absolutely do this via ajax so your options are either

  1. use small partial views. your view logic determines what to disable/enable

  2. (probably easier and more lightweight) use json to get a list of property names to disable.Then you can simply disable them via jQuery ideally by iterating through each item with the .each() call. See: looping through JSON array in a jQuery list for a use of the each call. got jQuery getJson, see: http://api.jquery.com/jQuery.getJSON/

so: 1. getJson to get the results from a controller 2. enumerate using .each() and set the property

 $("#" + yourFieldName).attr("disabled","disabled");

Upvotes: 2

Related Questions