整理一下大家熟悉的asp.net和cshtml之间容易出现错误的书写方法
错误:@Html.RenderPartial("_XXXX", Model);
正确:@{Html.RenderPartial("_XXXX", Model);}
错误:@using "...";
正确:@using ... ;(把引号去掉)
错误:
@{
for (int i = 0; i <= 15; i++)
{
//这里用到了i
}
}
正确:
@for (int i = 0; i <= 15; i++)
{
//这里用到了i
}
不好:(也能运行):
@foreach (var user in Roles.GetUsersInRole((string)ViewBag.OldRole))
{
@user
}
好:
@foreach (var user in Roles.GetUsersInRole((string)ViewBag.OldRole))
{
@user
}