0
이상한 문제가 있습니다.ValueProvide + MVC 4의 AttemptedValue 값을 설정하는 방법
내 MVC보기에 jQuery에서 렌더링되는 확인란이 있습니다.
<div>
<label for="check" class="chk">
Del ?
<input id="IsSoftDeleted" name="IsSoftDeleted" data-val-required="The Del? field is required." data-val="true" type="checkbox" class="check" />
</label>
</div>
스크립트는 체크 및 체크되지 않은 값이 온 및 오프로 설정되는 방식으로 작성되었습니다. 내 bodel 바인더 아래로 처리 한
:이 잘 작동
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
bool softDelete = Convert.ToBoolean(bindingContext.ValueProvider.GetValue("IsSoftDeleted").AttemptedValue != null
&& bindingContext.ValueProvider.GetValue("IsSoftDeleted").AttemptedValue == "on" ? "true" : "false");
return OrgFactory.Create(bindingContext.ValueProvider.GetValue("Caption").AttemptedValue,
bindingContext.ValueProvider.GetValue("NameInUse").AttemptedValue,
bindingContext.ValueProvider.GetValue("Description").AttemptedValue,
softDelete, new Party());
}
, 조직의 IsSoftDeleted의 속성은 이제 true 또는 false입니다.
그러나 내 Model 클래스의 부울 값에 IsSoftDeleted가 있기 때문에 ModelState는 시도 된 값 즉 on을 나타내고 ModelState는 false가됩니다.
값을 AttemptedValue 속성으로 설정하려고했으나 액세스 할 수 없습니다.
누군가가 조언을 해줄 수 있습니까?