I have a view which is nothing more than several hundred text boxes that are all generated from a buncha TextBoxFor
's. The original model is populated by deserializeing a json blob (string) saved in the DB. The user has the ability to change any one (or all) of the values, and when the Save button is clicked, I want to just return all the textbox values to a Json string and save that string back to the DB.
In the view...
function SaveAll() {
var model = '@Html.Raw(Json.Encode(Model))';
// Send the string to the server ...
}
While that does a great job of taking the model as delivered to the View and making a Json string out of it, it does not reflect any user changes to the model after it was delivered to the view.
I am REALLY hoping there is a simple way to get all the current textbox values and turn them into a Json string, without having to reference all hundred+ of them individually, and, of course, to maintain the structure of the original model.
Here's a sample of one of the Text Boxes after being rendered into HTML:
<input
class="form-control input-sm"
id="LeadPricingModel_CampaignType_Exclusive"
name="LeadPricingModel.CampaignType.Exclusive"
value="25">
The name, LeadPricingModel.CampaignType.Exclusive
, represents the structure of the model.