【发布时间】:2020-09-23 15:19:44
【问题描述】:
我有一个带有文本区域的表单,当我输入的字符数少于 200 时,工作正常。如果字符数限制超过 200,则在我提交表单时,我的整个模型将变为空。
所以我现在添加了最大长度属性,但我的要求是输入最大字符。我的代码sn-p如下
模型为
[BindProperty]
[Required(ErrorMessage ="notes are required")]
[MaxLength(200)]
public string Notes { get; set; }
我的控制器如下
[HttpPost]
[Route("notes")]
public async Task<JsonResult> AddNotes(ProfileReviewNotesViewModel model)
{
var response = await this.profileModelBuilder.SaveNots(model, UserId);
return Json(response);
}
请帮我解决这个问题。
【问题讨论】:
标签: asp.net-core