我正在开发一个MVC3项目,并且我最终试图对此进行排序。这可能是我忽视的超级简单的东西,但我现在看不到它。问题是当我点击Firefox中的提交按钮时,几乎没有任何反应。控制台中没有任何错误,它永远不会击中我的控制器,只是直接向上。看着我在Chrome中观看XHR请求,它完全符合预期。在firebug中观看XHR请求,什么都没有。
这是代码.. 视图。 - 这只是部分视图,在完整视图模板文件的头部,我确实包含了jquery.ajax-unobtrusive.js,Microsoft.ajax.js和Microsoft.mvcajx.js ...按顺序
@using Infragistics.Web.Mvc
@model FuelPortal.Models.ViewModels.UserMaintenanceViewModel
@*changed this div and ajax update from wrapperData to wrapperData because having it as wrapperData was screwing up the JS on user submit, it had two of the same id's...*@
<style type="text/css">
input[type=text]
{
margin-bottom: 10px;
}
.disabled
{
background-color: #CECECE !important;
background-image: url('') !important;
}
</style>
<script src="../../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<div id="wrapperData2">
<!-- jared's table thingymabobber starts here yo -->
@if (Model != null)
{
<div class='frmBG'>
<table width='100%' style='margin-top: 10px'>
@using (Ajax.BeginForm("DetailUser", new AjaxOptions { UpdateTargetId = "wrapperData2", InsertionMode = InsertionMode.Replace, HttpMethod = "POST" }))
{
<tr>
<td><b>First Name:</b></td>
<td>@Html.TextBoxFor(mbox => mbox.User.firstName)</td>
</tr>
<tr>
<td><b>Last Name:</b></td>
<td>@Html.TextBoxFor(mbox => mbox.User.lastName)</td>
</tr>
<tr>
<td><b>Email:</b></td>
<td>@Html.TextBoxFor(mbox => mbox.User.email)</td>
</tr>
<tr>
<td><b>Username:</b></td>
<td>@Html.TextBoxFor(mbox => mbox.User.userName, new {@readonly="true", @class="disabled"})</td>
</tr>
<tr>
<td><b>Phone:</b></td>
<td>@Html.TextBoxFor(mbox => mbox.User.phone)</td>
</tr>
<tr>
<td><b>Account Expiration Date:</b></td>
<td>@Html.TextBoxFor(mbox => mbox.User.expireDate)</td>
</tr>
<tr>
<td>@Html.HiddenFor(mbox => mbox.User.LoginAccountId)</td>
<td><input type="submit" value='Save' /></td>
</tr>
}
</table>
</div>
}
</div>
控制器操作 - 第一个操作是加载部分视图时执行的操作,在提交部分视图的表单时执行HTTP POST重载。
//view details
public ActionResult DetailUser(int id)
{
UserMaintenanceViewModel model = new UserMaintenanceViewModel();
model = repository.getUserById(Session["UserId"].ToString(), id);
return PartialView("_ViewUserDetail", model);
}
[HttpPost]
public ActionResult DetailUser(int id, UserMaintenanceViewModel model)
{
var test = model.User.LoginAccountId;
var test2 = model.User.firstName;
var result = repository.updateUser(model.User);
return PartialView("_ViewUserDetail", model);
}
非常感谢任何帮助,为每个人欢呼!