我有LogoutModel
个属性。我希望我的HomeController
更改此值,然后View
显示此值,但它似乎不起作用。显示退出视图时,它显示:'Goodbye Html.LabelFor(m => m.PreviouslyLoggedInUsername)'
LogoutModel:
public class LogoutModel
{
public string PreviouslyLoggedInUsername { get; set; }
}
HomeController中:
public ActionResult Logout(HomeModels.LogoutModel model)
{
model.PreviouslyLoggedInUsername = previousLoggedIn;
return View(model);
}
查看:
@using Ecommerce.Models
@model HomeModels.LogoutModel
@{
ViewBag.Title = "Logout";
Layout = "~/Views/Shared/Master.cshtml";
}
<h2>You have been logged out.</h2>
@using (Html.BeginForm())
{
<table>
<tr>
<td>
<label>Goodbye </label>
Html.LabelFor(m => m.PreviouslyLoggedInUsername)
</td>
</tr>
</table>
}
答案 0 :(得分:0)
您需要在@
Html.LabelFor...
符号
<table>
<tr>
<td>
<label>Goodbye </label>
@Html.LabelFor(m => m.PreviouslyLoggedInUsername)
</td>
</tr>
</table>