【发布时间】:2016-09-10 05:54:07
【问题描述】:
我有控制器端
ViewBag.CanAddNewStudent = Convert.ToBoolean(Request.Cookies["SignInOption"]["Can Add New Student"].Split(',')[0]);
在视图方面,我将隐藏字段作为
<input type="hidden" id="HiddenCanAddNewStudent" value="@ViewBag.CanAddNewStudent">
<label>@ViewBag.CanAddNewStudent</label>
【问题讨论】:
-
当我将值作为字符串传递时是可能的 ViewBag.CanAddNewStudent = Request.Cookies["SignInOption"]["Can Add New Student"].Split(',')[0];我不明白布尔值有什么问题。 @Html.Hidden("HiddenCanAddNewStudent", (bool)ViewBag.CanAddNewStudent) 也在工作,唯一的问题是
标签: html .net asp.net-mvc