razor新手,我有一个标签和一个按钮
<form action="" method="post" enctype="multipart/form-data">
<label name="Mylabel">Test + @ViewData["MyLabelUpdate"]</label>
<input type="submit" id="MyBtn" Value="Change Label">
现在在控制器中我有:
[HttpPost]
public ActionResult Index()
{
return RedirectToAction("Index");
}
如何使用actionresult方法更改标签?感谢
答案 0 :(得分:1)
你必须让你的控制器看起来像这样:
[HttpPost]
public ActionResult Index()
{
ViewBag.MyLabelUpdate = "whatever";
return RedirectToAction("Index");
}
而且,您的观点:
<form action="" method="post" enctype="multipart/form-data">
<label name="Mylabel">Test + @ViewBag.MyLabelUpdate</label>
<input type="submit" id="MyBtn" Value="Change Label">