日期:2014-05-20  浏览次数:20671 次

MVC3
@using (Html.BeginForm("Index", "Financlal", FormMethod.Post, new { id = "form_financlal_info" }))
{
@Html.Hidden("CarID$guid$key",carID)

<table>
<thead>      
<tr>
<td>加邮费:<input  type="text" value="@Common.GetValue(row, "Jiayoufei")" /></td>
<td>占标费:@Common.GetValue(row, "Zhanbiaofei") </td>
<td>采购成本:@Common.GetValue(row, "Caigouchengben")</td>
</tr>
</thead>
</table>
<input type="submit" value="保存" />
}
后台
  [HttpPost]
        public JsonResult Info(FormCollection form)
        {
            Dictionary<string, object> forms = new Dictionary<string, object>();
            form.CopyTo(forms);
            forms.Add("FinanciaID$guid", GetUserID());

            DataResult<Guid> result = BLL.Financlal.FinanclalFn.SaveInfo(forms);

            return Json(result, JsonRequestBehavior.AllowGet);
        }
为什么我点了页面的保存按钮它根本不走后台的方法
------解决方案--------------------
@using (Html.BeginForm("Index", "Financlal", FormMethod.Post, new { id = "form_financlal_info" }))

提交到controller="financlal" ,action="index"

你后台的action="Info",所以把Index替换为Info。
------解决方案--------------------
Html.BeginForm第一个参数是Action,第二个是Controller,就是Financlal中的Index方法,所以你的 Info改成Index,或者将第一个参数改为 Info