我尝试检查model.LastName是否为空以将属性设置为textBox,我收到此错误: 模型'与声明'System.Web.Mvc.WebViewPage.Model
冲突@Html.TextBoxFor(model => model.CellphonePrefix, new {title = (string.IsNullOrEmpty(Model.CellphonePrefix) ? "Requried" : "") })
错误与第二个模型有关:
title = (string.IsNullOrEmpty(Model.LastName) ? "Requried" : ""
标签在这里是完整的代码:
@model Models.UserViewModelR
@using (@Html.BeginForm("Register", "Start", FormMethod.Post, new { enctype = "multipart/form-data", onsubmit = "return validateForm()", lang = "he" }))
{
@Html.TextBoxFor(model => model.CellphonePrefix, new {title = (string.IsNullOrEmpty(Model.CellphonePrefix) ? "Requried" : "") })
}
有人可以帮忙吗?
答案 0 :(得分:0)
将model =>模型改为Model =>下面的模型代码试试这个
@model Models.UserViewModelR
@using (@Html.BeginForm("Register", "Start", FormMethod.Post, new { enctype
=
"multipart/form-data", onsubmit = "return validateForm()", lang = "he" }))
{
@Html.TextBoxFor(Model => Model.CellphonePrefix, new {title =
(string.IsNullOrEmpty(Model.CellphonePrefix) ? "Requried" : "") })
}