Controller页面:
public ActionResult Index(string name, int numTimes) { ViewBag.Message = "Hello " + name; ViewBag.NumTimes = numTimes; return View(); }
View页面:
<body> <ul> @for (int i = 0; i < ViewBag.NumTimes; i++) { <li> @ViewBag.message </li> } </ul> </body>
时间: 2024-10-07 21:05:03