Email Remote Validation is Sending Null Value to Action

时间:2017-12-18 08:09:49

标签: c# asp.net-mvc validation remote-validation

I am trying to validate email existence by using Remote validation.I have searched this on Stack-overflow but no answer works for me. The value sent to Validation method is null. Here is the Html form..

code    name    ear    value     add  value     ded  value
001     Nav     BASIC  1000.00   HR   600.00    PF   50.00
                FUEL   200.00    
                Mobile 300.00

Here is the action i am calling.

<div class="form-group">
    <label>Email</label>
    @Html.TextBoxFor(m => m.ObjMemberInfo.Email, new { @class = "form-control regcom", @placeholder = "Enter E-mail", maxlength = 45 })
    @Html.ValidationMessageFor(m => m.ObjMemberInfo.Email, "", new { @style = "color:red" })
</div>

Here is the ViewModel

public JsonResult CheckEmailExists_TeamMember([Bind(Prefix = "AreaTeamManagementViewModel.TeamMemberInfoViewModel.Email")]string Email)
{
    bool UserExists = false;
    try
    {
        var nameexits = db.UsersRegistrations.Where(m => m.Email == Email && m.Deleted != true && m.UserRole.RoleType == "TeamMember").ToList();
        if (nameexits.Count > 0)
        {
            UserExists = true;
        }
        else
        {
            UserExists = false;
        }
        return Json(!UserExists, JsonRequestBehavior.AllowGet);
    }
    catch (Exception)
    {
        return Json(false, JsonRequestBehavior.AllowGet);
    }
}

kindly suggest me any way to resolve this.Thanks

0 个答案:

没有答案