0

我有一个执行 HttpPost 的视图。

只要我只有文本框,它就可以正常工作。我添加了一个日期时间选择器和下拉列表,表单会在点击日期时间选择器和下拉列表时自动发布。我什至看不到日期时间选择器和下拉列表详细信息,它们只是出现和消失并形成帖子,并且显示所需的错误消息。

日期时间选择器和下拉列表是使用 jquery 小部件创建的。

有人可以建议如何停止在 MVC4 中自动发布表单吗?

以下是我的看法:

@using P.B.O
@model O

 @using (Html.BeginForm("Create", "O", FormMethod.Post))
 {

@Html.ValidationSummary(true)
<fieldset>
    <legend>Create a New Organization</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.C) 
        @Html.TextBoxFor(model => model.C, new { @class = "txt"}) 
        @Html.ValidationMessageFor(model => model.C) 
    </div> <br />

    <div class="editor-label">
        @Html.LabelFor(model => model.N)
        @Html.TextBoxFor(model => model.N, new { @class = "txt"}) 
        @Html.ValidationMessageFor(model => model.N)
    </div> <br />

    <div class="editor-label">
        @Html.LabelFor(model => model.D)
        @Html.TextBoxFor(model => model.D, new { @class = "txt"}) 
        @Html.ValidationMessageFor(model => model.D)
    </div> 

    <div>
        <label for="check" class="chk">
            Del ?
            <input id="IsSoftDeleted" name="IsSoftDeleted" data-val-required="The Del? field is required." data-val="true" type="checkbox" class="check"  />
        </label>
    </div>

    <br />

  <input id="FromDate" name ="FromDate" data-val="true" type="datetime" class="datetime" />

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

}

4

0 回答 0