umbraco mvc表单模型验证标记未显示

时间:2013-05-06 12:55:01

标签: asp.net-mvc razor validation umbraco

运行Umbraco 6.05,我有一个带有数据注释的自定义模型类,如:

[必需,StringLength(100),DataType(DataType.EmailAddress),DataType(DataType.MultilineText)]

我将模型传递给视图:

@inherits Umbraco.Web.Mvc.UmbracoViewPage<test.local.Models.ContactForm>

<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>ContactForm</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        ...

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

但是当它呈现时,“data-val”属性丢失了,尽管有趣的是DataType EmailAddress / MultiLine通过插入'type =“email”'并适当地创建'textarea'来正常工作。

任何想法我可能做错了什么?

干杯

1 个答案:

答案 0 :(得分:1)