我在控制器中有一个返回 3 个视图袋的操作。是否可以检查控制器发送的 Viewbag 的剃须刀。?
这是我的控制器
public ActionResult Details(string Query, long Id)
{
// some code......
switch (Query)
{
case ("Operationer"):
ViewBag.Query =Operationer;
break;
case ("Material"):
ViewBag.Query = Material;
break;
Case("items"):
Viewbag.Query= items;
break;
}
return view();
}
在我的剃刀视野中
@{
ViewBag.Title = "Details";
Layout = "~/Views/Shared/LayoutDetails.cshtml";
}
<h2>Details</h2>
@ if ( the incom Viewbag == "material")
{
Create table for material
}
@ else if ( the income Viewbaf == "items")
{
create table for items
}