1

我正在开发一个 MVC3 项目,并且正在努力解决这个问题。这可能是我忽略的超级简单的事情,但我现在看不到它。问题是当我在 Firefox 中单击提交按钮时,实际上没有任何反应。控制台中没有错误,它永远不会碰到我的控制器,只是什么都没有。看着我在 chrome 中观看 XHR 请求,它完全符合它的预期。在萤火虫中观看 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);
    }

非常感谢任何帮助,为大家欢呼!

4

0 回答 0