MVC View 传数字 诡异变值
题目 只是我自己碰到问题前想问的问题,经过几个小时奋斗终于才出来问题所在。
最近在用MVC做项目,也是第一次正实自己使用它做项目,公司用的是自己写的前端框架
前面都是废话,可略过不看
直接上原因吧
从列表页点击弹出编辑视图

Controller Code:
public ActionResult CreateChildren(string fatherID, int level)
{
......
var model = new 实体类名() { FatherID = fatherID, Level = (level + 1) };
return View("Edit", model);
}
编辑视图:
@Html.HiddenFor(m => m.Level)
从上面看,很明显是URL编号和视图Hidden的名字冲突导致
于是改了
href="@Url.Action("CreateChildren", new { fatherID = m.ID,fatherLevel=m.Level })&TB_iframe=true&height=600&width=650">
Controller Code:
public ActionResult CreateChildren(string fatherID, int fatherLevel)
{
......
var model = new 实体类名() { FatherID = fatherID, Level = (fatherLevel + 1) };
return View("Edit", model);
}
于是对了
希望对有些朋友有点点用!

浙公网安备 33010602011771号