the problem razor (mvc 5) renders out hiddenfor , hidden helper incorrectly.
i have view model this:
public class myviewmodel { public bool boolvalueinsideviewmodel { get; set; } public myviewmodel() { boolvalueinsideviewmodel = false; } }
and controller simple as:
model = new myviewmodel(); model.boolvalueinsideviewmodel = false; return partialview("_myview", model);
second line sure value set false. view looks this:
@model myviewmodel @html.hidden("boolvalueinsideviewmodel", false) @html.hidden("boolvaluenotinviewmodel", false)
but on browser this:
<input data-val="true" data-val-required="the boolvalueinsideviewmodel field required." id="boolvalueinsideviewmodel" name="boolvalueinsideviewmodel" type="hidden" value="true"> <input id="boolvaluenotinviewmodel" name="boolvaluenotinviewmodel" type="hidden" value="false">
note have 15 other view models , controller methods in same controller works fine same code (i use hiddenfor typed values normaly, here changed hidden show not work hard coded value in view).
putting break point on view, shows model has boolvalueinsideviewmodel equal false, result on browser different. result via jquery post callback, checked raw string returning ajax function , value there "true" instead of false.
what tried:
- clean project , rebuild!
- renaming property
- renaming view model, renaming file containing view model
- renaming view
i know! looks stupid , simplest thing on asp.net mvc, spent half day on it. other view models , partial views render correctly.
the weird thing don't have data annotation on view model, why includes data validation attributes on html element?
Comments
Post a Comment