【发布时间】:2018-06-15 23:49:09
【问题描述】:
这是打开模态框的按钮(有效):
<button data-toggle="modal" data-target="#modal-addItem-@sectionCount-@rowCount" class="btn btn-success">Add New List Item</button>
这里是模态:
<div id="modal-addItem-@sectionCount-@rowCount" role="dialog" aria-hidden="true" aria-labelledby="modal-addItem-@sectionCount-@rowCount" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Added List Item</h4>
</div>
@Html.Partial("_SelectItemType", new ListItemsViewModel { listID = theLists.listID })
</div>
</div>
</div>
这是部分视图更新:
@using (Html.BeginForm("SelectItemType", "ListItems", null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(model => model.listID)
<div class="modal-body">
<div class="form-group">
<b class="control-label col-md-4">Select List Item Type:</b>
<div class="col-md-8">
@Html.DropDownListFor(model => model.ItemTypes.itemTypeName, DropDown.GeneralListCreator(get.getItemTypes(true), get.getItemTypes(false))) //This gets a list of item types
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-default" data-dismiss="modal">Close</a>
<input type="submit" value="Next Step »" class="btn btn-primary" />
</div>
}
所以当我点击按钮时,它会按原样打开模式。当我单击“下一步>>”按钮时,该按钮是表单上的提交按钮。 没有回发,没有提交表单...什么也没有发生。
我不确定为什么这不起作用...谁能指出我做错了什么?如果您需要更多信息,请告诉我。
提前致谢。
更新:正如 Chris 指出的那样,我尝试删除 Section 脚本(因为它已经在视图中),但它仍然没有提交。
【问题讨论】:
-
您的代码中没有任何内容可以阻止此操作。虽然,FWIW,你不能在局部视图中实现一个部分。不过,这不应该引起任何问题;它只是不包含您的验证脚本。
-
您是否启用了客户端验证?可能不会阻止表单提交?
-
好线索,我在部分视图
@Html.ValidationMessageFor(model => model.ItemTypes.itemTypeName)的下拉列表下方添加了此消息,并收到此消息:项目类型名称必须至少 2 个字符长且不超过 250字符。 这是验证消息。我将尝试从这里解决更多问题。好指针。
标签: c# asp.net-mvc html bootstrap-modal client-side-validation