Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到Viewmodel属性_C#_Asp.net Mvc_Asp.net Mvc Viewmodel - Fatal编程技术网

C# 找不到Viewmodel属性

C# 找不到Viewmodel属性,c#,asp.net-mvc,asp.net-mvc-viewmodel,C#,Asp.net Mvc,Asp.net Mvc Viewmodel,提交表单时,我遇到一个错误,该错误表示找不到viewmodel中没有的某些属性“密码” System.ArgumentException:找不到属性ProjectName.ViewModels.User.UserSecurityViewModel.Password 这是我的html表单 更改密码 旧密码 新密码 确认密码 一些测试文本@Html.ValidationSummary(“,new{@class=“text danger”}) 更新密码 你可能是想把新密码放在这里,如果这是你比较

提交表单时,我遇到一个错误,该错误表示找不到viewmodel中没有的某些属性“密码”

System.ArgumentException:找不到属性ProjectName.ViewModels.User.UserSecurityViewModel.Password

这是我的html表单


更改密码
旧密码
新密码
确认密码
一些测试文本@Html.ValidationSummary(“,new{@class=“text danger”})
更新密码
你可能是想把新密码放在这里,如果这是你比较的话

[DataType(DataType.Password)]
    [System.ComponentModel.DataAnnotations.Compare("NewPassword", ErrorMessage = "The confirm password does not match, type again!")]
    public string ConfirmPassword { get; set; }
你可能是想把新密码放在这里,如果这是你比较的话

[DataType(DataType.Password)]
    [System.ComponentModel.DataAnnotations.Compare("NewPassword", ErrorMessage = "The confirm password does not match, type again!")]
    public string ConfirmPassword { get; set; }

我遇到了完全相同的问题,这是由来自register page ViewModel的复制粘贴引起的


正如另一位用户指出的,问题出在Compare DataAnnotation中。

我遇到了完全相同的问题,它是由来自register page ViewModel的复制粘贴引起的


正如另一位用户所指出的,问题在于Compare DataAnnotation。

您不是认真地像那样手动生成html吗?使用
HtmlHelper
方法(例如
Html.PasswordFor(m=>m.OldPassword,new{@class=“…”})
生成用于客户端验证的
data val-*
属性,并具有双向模型绑定。您没有像这样认真地手动生成Html吗?请使用
HtmlHelper
方法(例如,
Html.PasswordFor(m=>m.OldPassword,new{@class=“…”})
为客户端验证生成
数据val-*
属性,并具有双向模型绑定。