I'm using ASP.net MVC 5
with Razor Engine
. I want to create a page to register users . I create a Model and MetaData model for my User entity . All my codes are here . I think everything is Ok but I got this compile error :
Compiler Error Message: CS1061: 'NP1.ViewModels.RegisterVM' does not contain a definition for 'UserEmail' and no extension method 'UserEmail' accepting a first argument of type 'NP1.ViewModels.RegisterVM' could be found (are you missing a using directive or an assembly reference?)
Could anyone help me how fix it,please ?
controller
[HttpGet]
public ActionResult Register()
{
RegisterVM vm = new RegisterVM();
vm.UserAddress = "";
vm.UserBirthDate = DateTime.Now;
vm.UserCellPhone = "";
vm.UserEmail = "";
vm.UserFirstName = "";
vm.UserGender = "";
vm.UserID = 1;
vm.UserImage = "";
vm.UserLastName = "";
vm.UserPassWord = "";
vm.UserStatus = 1;
vm.UserTell = "";
return View(vm);
}
RegisterVM
public List<SocialNetwork> SocialNetworks { get; set; }
public List<Footer> Footers { get; set; }
public List<FooterMenu> FooterMenus { get; set; }
public List<User> Users { get; set; }
Register.cs
@model NP1.ViewModels.RegisterVM
@{
ViewBag.Title = "Register";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>User</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.UserEmail, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserEmail)
@Html.ValidationMessageFor(model => model.UserEmail)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserFirstName, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserFirstName)
@Html.ValidationMessageFor(model => model.UserFirstName)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserLastName, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserLastName)
@Html.ValidationMessageFor(model => model.UserLastName)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserPassWord, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserPassWord)
@Html.ValidationMessageFor(model => model.UserPassWord)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserCellPhone, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserCellPhone)
@Html.ValidationMessageFor(model => model.UserCellPhone)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserTell, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserTell)
@Html.ValidationMessageFor(model => model.UserTell)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserImage, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserImage)
@Html.ValidationMessageFor(model => model.UserImage)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserAddress, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserAddress)
@Html.ValidationMessageFor(model => model.UserAddress)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserStatus, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserStatus)
@Html.ValidationMessageFor(model => model.UserStatus)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserBirthDate, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserBirthDate)
@Html.ValidationMessageFor(model => model.UserBirthDate)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.UserGender, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserGender)
@Html.ValidationMessageFor(model => model.UserGender)
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>