MVC 3 View 与部分视图和 Ajax 表单
这是我的困境。我有一个 MVC 3 网站,并且有一个页面需要包含子表单(如果您愿意的话)来收集与我的模型相关的一些数据。我已经成功创建了包含标记的部分视图,并且我正在正确渲染它。然而,部分视图中的输入按钮似乎没有做任何事情。这是分部视图中的表单:
@using (Ajax.BeginForm("AddProductCustomField", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "addCustomFieldView" }))
{
@Html.DropDownListFor(m => m.SelectedCustomFieldId, new SelectList(Model.CustomFields, "FieldId", "FieldName"), "-- Select One --", new { @class = "int_std_select" })<text> </text>
@Html.TextBoxFor(m => m.CustomFieldValue, new { @class = "int_std_textbox" })
<input type="submit" value="Add Custom Field" /><br />
}
“AddProductCustomField”是我想要处理此表单帖子的控制器方法的名称。但是,单击提交按钮不会执行任何操作。我什至打开 Fiddler 来查看请求是否被吃掉,但什么也没有。我已经包含了该页面的所有适当的 JavaScript 文件(MicrosoftAjax、MicrosoftMvcAjax 和不显眼的 JavaScript)。我很困惑。
如果我需要提供更多信息,请告诉我。非常感谢,这个问题困扰我好几天了!
Here is my quandary. I have an MVC 3 web site, and I have a page that needs to contain a sub-form, if you will, to collect some data related to my model. I have successfully created a partial view that contains the markup and I am rendering this properly. However, the input button in the partial view doesn't seem to be doing much of anything. Here is the form in the partial view:
@using (Ajax.BeginForm("AddProductCustomField", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "addCustomFieldView" }))
{
@Html.DropDownListFor(m => m.SelectedCustomFieldId, new SelectList(Model.CustomFields, "FieldId", "FieldName"), "-- Select One --", new { @class = "int_std_select" })<text> </text>
@Html.TextBoxFor(m => m.CustomFieldValue, new { @class = "int_std_textbox" })
<input type="submit" value="Add Custom Field" /><br />
}
"AddProductCustomField" is the name of my controller method that I want to handle this form post. However, clicking the submit button does nothing. I even popped open Fiddler to see if a request was getting eaten and nothing. I've included all the appropriate JavaScript files for this page (MicrosoftAjax, MicrosoftMvcAjax and the unobtrusive JavaScript). I'm stumped.
Please let me know if I need to provide more info. Thanks much, this has been stumping me for days!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提到了子表单。您的字面意思是嵌套形式吗? HTML 不支持这一点,所以我认为这可能是问题的根源。
You mentioned sub-form. Do you literally mean you are nesting forms? This is not supported in HTML, so I would think that's probably the source of your problem.