我有一个带有char
属性的简单视图模型。。。
public char Character1 { get; set; }
默认模型绑定似乎没有将空格字符(")转换为此属性,导致以下ModelState错误。。。
The Character1 field is required.
html输入元素是用javascript:创建的
var input = $('<input type="password" name="Character' + i + '" id="input-' + i + '" data-val="true" data-val-custom maxlength="1"></input>');
- 该属性上没有
[Required]
属性 - 发布的值在模型错误
AttemptedValue
属性中肯定是" - 由于上述错误,
ModelState.IsValid
返回false - 绑定后,模型属性具有空字符值