C# 部分视图表单将不会使用引导模式提交

C# 部分视图表单将不会使用引导模式提交,c#,asp.net-mvc,html,bootstrap-modal,client-side-validation,C#,Asp.net Mvc,Html,Bootstrap Modal,Client Side Validation,下面是打开模式框的按钮,它可以工作: <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="t

下面是打开模式框的按钮,它可以工作:

<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">&times;</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>
以下是已更新的局部视图:

因此,当我点击按钮时,它会打开模态。当我点击下一步>>按钮时,它是表单上的提交按钮。没有回帖,没有表单提交…什么都没有发生

我不知道为什么这行不通……谁能指出我做错了什么?如果你需要更多信息,请告诉我

提前谢谢


更新:正如Chris指出的,我试图删除部分脚本,因为它已经在视图中,但它仍然没有提交

所以答案当然很简单。我找到了这个页面:

这让我找到了Vsevolod善意指出的答案。正在客户端启用验证。我以前没有输出消息,所以我不知道。当我补充说:

@Html.ValidationMessageFor(model => model.ItemTypes.itemTypeName)
在表格中,我可以看到以下信息:

The Item Type Name must be at least 2 characters long and no longer than 250 characters.
我的下拉列表由以下方法填充:get.getItemTypesfalse,如果为true,则返回name,如果为false,则返回Numbersids。id是1-9,只有一个数字。我需要2个字符来验证。因此,它没有提交

我的解决方案由顶部链接提出:

@{ Html.EnableClientValidation(false); }
@Html.DropDownListFor(model => model.ItemTypes.itemTypeName, DropDown.GeneralListCreator(get.getItemTypes(true), get.getItemTypes(true)))
@Html.ValidationMessageFor(model => model.ItemTypes.itemTypeName)
@{ Html.EnableClientValidation(true); }
出于某种原因,即使我更改了get.getItemTypesfalse方法以返回发送的名称true,验证仍然无法正常工作,因此我必须关闭并重新打开它


谢谢大家的帮助

这就是帮助我的原因:

尝试添加


data toggle=modal data target=modal addItem-@sectionCount-@rowcount您的代码中没有任何内容会阻止此操作。尽管如此,FWIW不能在局部视图中实现剖面。不过,这不会造成任何问题;它只是不包括您的验证脚本。您是否启用了客户端验证?可能它不会阻止表单提交?很好的线索,我在我的部分视图中的下拉列表下方添加了此项@Html.ValidationMessageFormodel=>model.ItemTypes.itemTypeName,并收到此消息:项目类型名称必须至少2个字符长且不超过250个字符。这是验证消息。我将尝试从这里排除更多故障。好球。
@{ Html.EnableClientValidation(false); }
@Html.DropDownListFor(model => model.ItemTypes.itemTypeName, DropDown.GeneralListCreator(get.getItemTypes(true), get.getItemTypes(true)))
@Html.ValidationMessageFor(model => model.ItemTypes.itemTypeName)
@{ Html.EnableClientValidation(true); }