I have the following model:
public class RegisterUseraccount
{
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = \"E-Mail-Adresse\")]
Maybe you have this model
public class YourModel
{
public RegisterUseraccount RegisterUseraccount { get; set; }
}
In this case you have to put the model that corresponds to your action:
[HttpPost]
public ActionResult Register(YourModel model)
{
var registerUseraccount = model.RegisterUseraccount;
...
}
Or:
@using (Html.BeginForm("Register", "Useraccount", FormMethod.Post, new { id = "registerUseraccountForm", @class = "ym-form" }))
{
@{ Html.RenderPartial("RegisterUseraccount"); }
}
RegisterUseraccount.cshtml
@model YourNamespace.RegisterUseraccount
@Html.ValidationSummary(true)
@Html.LabelForRequired(model => model.FirstName, null)
@Html.EditorFor(model => model.FirstName, new { required = "required", name = "firstName" })
@Html.ValidationMessageFor(model => model.FirstName)
but you'll have to change some things like @Html.ValidationSummary (true).
Edit
or most simple:
data: $("#registerUseraccountForm").serialize().replace("RegisterUseraccount.",""),
Edit II
data: $("#registerUseraccountForm").serialize().replace(/RegisterUseraccount./g,""),