i have a post method like this
[HttpPost]
public ActionResult Activatecard(ActivateCardViewModel model)
i then do things, and at the end of the method i do this
ActivateCardViewModel m = new ActivateCardViewModel();
m.Currency = partner.DefaultCurrency;
m.ActivateAmountCents = "00";
return View(m);
so, what i expected, was that the view was rendered with this new ActivateCardViewModel object, and the 2 properties filled (and shown in the view). (in the get i do the same, and it does work there)
but, as you might guess right now :) it doesn't!
it remembers (shows) everything from the posted object (model).
i hope it's by design, and someone can tell me why....
EDIT
when i post 56 cents and i put, as shown in the code, 00 cents in the new object, it still shows the 56 cents, thus it looks at it is right ignoring my new 'm' variable
Are you using HtmlHelpers?
If the ModelState contains a key for the same name as any HtmlHelper form fields the HtmlHelpers will use the ModelState value before using the Models value. The only way to reset this is to adjust ModelState entries.
ModelState.Clear();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With