1
我構建流利的助手,用於在ASP MVC中構建html表單。 但客戶驗證工作在這種情況下工作。 請幫我理解爲什麼在我的幫手「EditorFor」不添加客戶端驗證。ASP MVC客戶端驗證和流利的幫手
@using (Html.BeginForm())
{
var html = Html.TextBoxFor(c => c.UserName); // Good example client validation
<input type="submit" value="ok" />
}
@FormHelpers.Form(Html.Form()
.Title("Connection utilisateur")
.Error("")
.AddMessage("Entrez vos identifiant.")
.AddRow(row => row
.AddField(
"Nom utilisateur",new EditItem()
{
Value = Html.TextBoxFor(model => model.UserName),
// Validation client is not added !
Error = Html.ValidationMessageFor(model => model.UserName),
}
))
.AddRow(row => row
.AddField(
"Mot de passe",
Html.Edit(model => model.Password)))
.AddRow(row => row
.AddField(
"Se souvenir<br/> de moi",
Html.Edit(model => model.Souvenir)))
.Build())
我的生成器梅索德:
public FormViewModelBuilder AddRow(Func<FormRowViewModelBuilder, FormRowViewModelBuilder> rowBuildFunc)
{
FormRowViewModelBuilder builderRow = new FormRowViewModelBuilder();
FormRowViewModel row = rowBuildFunc(builderRow).FormRowViewModel;
FormViewModel.AddRow(row);
return this;
}
public FormRowViewModelBuilder AddField(string title, EditItem value)
{
FormFieldViewModel info = new FormFieldViewModel();
info.Title = title;
info.EditItem = value; **// Validation is not added !**
FormRowViewModel.Fields.Add(info);
return this;
}
是的,我有好的劇本和web.config中configurate。問題是流利的編輯器不在MvcForm塊中。 – neoncyber