E
E
Eugene2012-11-09 09:00:20
ASP.NET
Eugene, 2012-11-09 09:00:20

Does Html.ValidationSummary not always work?

Good day.
The project has forms that are validated using the ValidationSummary - class (System.Web.UI.WebControls). For example,

@using (Html.BeginForm("Edit", "Account"))
{
     @Html.ValidationSummary(true)
     <td>@Html.LabelFor(model => model.MobilePhone)</td>
     <td>
          @Html.TextBoxFor(model => model.MobilePhone)
          @Html.ValidationMessageFor(model => model.MobilePhone)
     </td>
}

Later, I rewrote the Html.BeginForm method and got Html.PopUpFormBegin("Edit", "Account") and Html.PopUpFormEnd()
@Html.PopUpFormBegin("Edit", "Account")
     @Html.ValidationSummary(false)
     <tr>
        <td>Дата открытия регистрации с</td>
        <td>@Html.TextBoxFor(m => m.DateStart)
            @Html.ValidationMessageFor(m => m.DateStart)</td>
    </tr>
@Html.PopUpFormEnd()

This is a partial view. It returns to the main page in a pop-up window with ajax using Json.
If you view the code in a firebug, no attributes are added to the text field.
Tell me what could be the problem? In the case of Html.BeginForm, everything is ok.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
graycrow, 2012-11-09
@Qwofer

Here's what your helper might look like, which can be used with using:

public static MvcForm PopUpForm(this HtmlHelper htmlHelper, string actionName, string controllerName, string validation = "", string idContent = null)
{
    return htmlHelper.BeginForm(actionName, controllerName, FormMethod.Post, new { onSubmit="return PopUpWindow.ExecuteForm(this, '" + validation + "', '" + idContent + "');" });
}

G
graycrow, 2012-11-09
@graycrow

Are jquery.validate.unobtrusive.js and jquery.validate.js included?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question