c# - Default constructor being called during POST and I lose all model data -
c# - Default constructor being called during POST and I lose all model data -
i having problem form posting , model beingness lost. page posted .net calling default constructor of object though object exists.
i have 2 actions, 1 , 1 post
[httpget] public actionresult quote(string sku, string network, string grade ) { quotemodel qm = new quotemodel(); // build model here homecoming view("quote", qm); } [httppost] public actionresult quote(quotemodel qm, string grade, string network) { // update model homecoming view("quote",qm); } the function works form posted, default constructor called , lose model data.
my view like:
@model pricecompare.models.quotemodel <div class="clarify"> @if (model.clarify == true) { using (html.beginform("quote", "home", formmethod.post)) { @html.dropdownlist("network", model.availablenetworks); @html.dropdownlist("grade", model.grades); <button type="submit">get quote</button> } } </div> why default contructor beingness called when there existing model pass back?
i have tried specifying model in form like:
using (html.beginform("quote", "home", new { @qm = model}, formmethod.post) if default constructor not beingness called qm null.
i've been going round in circles here trying figure out. can explain doing wrong?
c# razor asp.net-mvc-5
Comments
Post a Comment