ASP.NET MVC 3 Remote validation to allow original value

后端 未结 1 867
Happy的楠姐
Happy的楠姐 2021-02-06 08:36

I have a Remote attribute on the email property of my User model. When I create a new user, it works create and tells the users that an e-mail is already in use. Now I\'m having

相关标签:
1条回答
  • 2021-02-06 09:07

    I figured it out.

    In my view, I put @Html.Hidden("InitialEmail", Model.Email)

    On my Model, I put [Remote("IsEmailUsed", "User", AdditionalFields="InitialEmail")]

    And then in my controller action, I have public JsonResult IsEmailUsed(string email, string initialEmail) which will allow the initial e-mail to be valid.

    0 讨论(0)
提交回复
热议问题