2

我在向元素显示错误消息时遇到了一个问题。

是否有任何选项可以在 Html.ValidationMessageFor(model => model.ConfirmPassword) 的位置打开消息。因为对我来说它没有出现。我也想获得摘要和近场信息,而不仅仅是红色边框。有谁知道怎么做?

 using (Ajax.BeginForm("CreateValidForm", "Test", new AjaxOptions { HttpMethod = "Post" }))    {%> <div id="validationSummary1">
    <%= Html.ValidationSummary(true)%> </div> <fieldset>
    <legend>Fields</legend>
    <div class="editor-label">
        <%= Html.LabelFor(model => model.Name)%>
    </div>
    <div class="editor-field">
        <%= Html.TextBoxFor(model => model.Name)%>
        <%= Html.ValidationMessageFor(model => model.Name)%>
    </div>
    <div class="editor-label">
        <%= Html.LabelFor(model => model.Email)%>
    </div>
    <div class="editor-field">
        <%= Html.TextBoxFor(model => model.Email)%>
        <%= Html.ValidationMessageFor(model => model.Email)%>
    </div>
    <div class="editor-label">
        <%= Html.LabelFor(model => model.Password)%>
    </div>
    <div class="editor-field">
        <%= Html.TextBoxFor(model => model.Password)%>
        <%= Html.ValidationMessageFor(model => model.Password)%>
    </div>
    <div class="editor-label">
        <%= Html.LabelFor(model => model.ConfirmPassword)%>
    </div>
    <div class="editor-field">
        <%= Html.TextBoxFor(model => model.ConfirmPassword)%>
        <%= Html.ValidationMessageFor(model => model.ConfirmPassword)%>
    </div>
    <p>
        <input type="submit" value="Create" />
    </p> </fieldset> <% } %> <%= Html.ClientSideValidation<ValidModel>()
    .UseValidationSummary("validationSummary1", "Please fix the following problems:") %>

这是示例项目http://www.sendspace.com/file/m9gl54的链接 。

4

0 回答 0